Skip to content
Snippets Groups Projects
Commit ef30f29d authored by buczekp's avatar buczekp
Browse files

[LMS-2281] table editing for boolean and date properties

SVN: 21699
parent 42dfcc04
No related branches found
No related tags found
No related merge requests found
......@@ -16,10 +16,15 @@
package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid;
import java.util.Date;
import com.extjs.gxt.ui.client.event.FieldEvent;
import com.extjs.gxt.ui.client.widget.form.CheckBox;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.grid.CellEditor;
import com.google.gwt.event.dom.client.KeyCodes;
import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.field.DateFormField;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataTypeCode;
/**
......@@ -50,10 +55,53 @@ public class ColumnUtils
}
}
};
return editor;
break;
case BOOLEAN:
CheckBox checkBox = new CheckBox();
editor = new StringBasedCellEditor(checkBox);
break;
case TIMESTAMP:
editor = new StringBasedCellEditor(new DateFormField("", false));
break;
default:
editor = new CellEditor(new DefaultCellEditorField());
return editor;
}
return editor;
}
/**
* Extension of GXT {@link CellEditor} with automatic conversion from String values that we hold
* in tables to specific data types (like {@link Date} or {@link Boolean}) handled by editor
* fields and vice versa.
*/
private static class StringBasedCellEditor extends CellEditor
{
public StringBasedCellEditor(Field<? extends Object> field)
{
super(field);
}
@Override
public Object preProcessValue(Object value)
{
if (value == null)
{
return value;
}
return getField().getPropertyEditor().convertStringValue(value.toString());
}
@Override
@SuppressWarnings("unchecked")
public Object postProcessValue(Object value)
{
if (value == null)
{
return value;
}
return getField().getPropertyEditor().getStringValue(value);
}
}
}
......@@ -82,13 +82,15 @@ public class TableCellUtil
case VARCHAR:
case MULTILINE_VARCHAR:
case BOOLEAN:
// case CONTROLLEDVOCABULARY:
case TIMESTAMP:
// case CONTROLLEDVOCABULARY:
// case MATERIAL:
return true;
default:
return false;
}
}
private TableCellUtil()
{
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment