From fa3d00924b3897e0e866ca61314b228a778c2449 Mon Sep 17 00:00:00 2001 From: tpylak <tpylak> Date: Fri, 17 Oct 2008 09:46:45 +0000 Subject: [PATCH] LMS-607 mark invalid samples SVN: 8678 --- .../ui/sample_browser/CommonColumns.java | 2 +- .../ui/sample_browser/SampleRenderer.java | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample_browser/SampleRenderer.java 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 00fe612d7ce..07900beaee8 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 00000000000..1fc465bc18e --- /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; + } + } + +} -- GitLab