From 151045d8d39f78273d3a0699d385c5cb00bf33f3 Mon Sep 17 00:00:00 2001
From: gpawel <gpawel>
Date: Wed, 22 Jun 2011 09:08:18 +0000
Subject: [PATCH] bugfix: table editing dates and vocabularies

SVN: 21796
---
 .../VocabularyTermStringCellRenderer.java         | 15 +++++++++------
 .../client/application/ui/grid/ColumnUtils.java   |  9 +++++----
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/renderer/VocabularyTermStringCellRenderer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/renderer/VocabularyTermStringCellRenderer.java
index 31da67387ba..57e755749bd 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/renderer/VocabularyTermStringCellRenderer.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/renderer/VocabularyTermStringCellRenderer.java
@@ -44,17 +44,20 @@ public class VocabularyTermStringCellRenderer implements GridCellRenderer<BaseEn
             {
                 return "";
             }
-            ISerializableComparable cell = values.get(columnIndex);
+
+            ISerializableComparable cell = null;
+            if (obj instanceof VocabularyTerm)
+            {
+                cell = new VocabularyTermTableCell((VocabularyTerm) obj);
+                values.set(columnIndex, cell);
+            }
+
+            cell = values.get(columnIndex);
             if (cell instanceof VocabularyTermTableCell == false)
             {
                 return cell.toString();
             } else
             {
-                if (obj instanceof VocabularyTerm)
-                {
-                    cell = new VocabularyTermTableCell((VocabularyTerm) obj);
-                    values.set(columnIndex, cell);
-                }
 
                 VocabularyTermTableCell vocabularyTermTableCell = (VocabularyTermTableCell) cell;
                 VocabularyTerm vocabularyTerm = vocabularyTermTableCell.getVocabularyTerm();
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnUtils.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnUtils.java
index 7e95119d16a..457cce849b3 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnUtils.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/ColumnUtils.java
@@ -29,6 +29,7 @@ import com.extjs.gxt.ui.client.widget.form.SimpleComboBox;
 import com.extjs.gxt.ui.client.widget.grid.CellEditor;
 import com.google.gwt.event.dom.client.KeyCodes;
 
+import ch.systemsx.cisd.common.shared.basic.utils.StringUtils;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.VocabularyTermModel;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.columns.framework.IColumnDefinitionUI;
@@ -195,9 +196,9 @@ public class ColumnUtils
         @Override
         public Object preProcessValue(Object value)
         {
-            if (value == null)
+            if (StringUtils.isBlank(value))
             {
-                return value;
+                return null;
             }
             return getField().getPropertyEditor().convertStringValue(value.toString());
         }
@@ -206,9 +207,9 @@ public class ColumnUtils
         @SuppressWarnings("unchecked")
         public Object postProcessValue(Object value)
         {
-            if (value == null)
+            if (StringUtils.isBlank(value))
             {
-                return value;
+                return null;
             }
             return getField().getPropertyEditor().getStringValue(value);
         }
-- 
GitLab