diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/CommonColumns.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/CommonColumns.java index 00fe612d7ceec3f621aa4427914ebc0e28cbcf2c..07900beaee8082e775bdc0902f3b96ded53b7124 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/CommonColumns.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/CommonColumns.java @@ -65,6 +65,7 @@ class CommonColumns columnConfig.setId(SampleModel.SAMPLE_CODE); columnConfig.setHeader("Code"); columnConfig.setWidth(100); + columnConfig.setRenderer(new SampleRenderer()); return columnConfig; } @@ -119,5 +120,4 @@ class CommonColumns columnConfig.setHidden(true); return columnConfig; } - } \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleRenderer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleRenderer.java new file mode 100644 index 0000000000000000000000000000000000000000..1fc465bc18eab10631b75a50529077798cd9d911 --- /dev/null +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleRenderer.java @@ -0,0 +1,51 @@ +/* + * Copyright 2008 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.sample_browser; + +import com.extjs.gxt.ui.client.data.ModelData; +import com.extjs.gxt.ui.client.store.ListStore; +import com.extjs.gxt.ui.client.widget.grid.ColumnData; +import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer; +import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; + +/** + * Renders sample code and marks if the sample is invalid + * + * @author Tomasz Pylak + */ +public class SampleRenderer implements GridCellRenderer<ModelData> +{ + + public String render(ModelData model, String property, ColumnData config, int rowIndex, + int colIndex, ListStore<ModelData> store) + { + String code = (String) model.get(SampleModel.SAMPLE_CODE); + boolean isInvalid = (Boolean) model.get(SampleModel.IS_INVALID); + if (isInvalid) + { + Element div = DOM.createDiv(); + div.setAttribute("class", "invalidated-sample"); + div.setInnerText(code); + return DOM.toString(div); + } else + { + return code; + } + } + +}