From fd43d41a079c58110e3502536f7eb97d8feeb39d Mon Sep 17 00:00:00 2001 From: tpylak <tpylak> Date: Wed, 13 Apr 2011 12:03:10 +0000 Subject: [PATCH] LMS-2163 fix links to materials in well search table SVN: 20880 --- .../client/application/ui/TypedTableGrid.java | 16 ++-- .../MaterialReplicaFeatureSummaryViewer.java | 18 ++-- .../detailviewers/WellSearchGrid.java | 91 ++++++++++++++++++- .../web/server/WellContentProvider.java | 12 +-- .../MaterialAllReplicasFeatureVectors.java | 1 + .../dto/grids/WellSearchGridColumnIds.java | 47 +++++++++- 6 files changed, 158 insertions(+), 27 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/TypedTableGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/TypedTableGrid.java index b502a7fc8b1..8ed85d25a80 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/TypedTableGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/TypedTableGrid.java @@ -231,7 +231,7 @@ public abstract class TypedTableGrid<T extends ISerializable> for (TableModelColumnHeader header : headers) { String id = header.getId(); - if (listenerLinkGenerators.containsKey(id)) + if (tryGetCellListenerAndLinkGenerator(id) != null) { definitions.setGridCellRendererFor(id, LinkRenderer.createLinkRenderer(true)); } else @@ -322,20 +322,19 @@ public abstract class TypedTableGrid<T extends ISerializable> for (final TableModelColumnHeader header : headers) { String title = header.getTitle(); + String columnId = header.getId(); if (title == null) { - title = - viewContext.getMessage(translateColumnIdToDictionaryKey(header - .getId())); + title = viewContext.getMessage(translateColumnIdToDictionaryKey(columnId)); } // support for links in queries ICellListenerAndLinkGenerator<T> linkGeneratorOrNull = - listenerLinkGenerators.get(header.getId()); + tryGetCellListenerAndLinkGenerator(columnId); final EntityKind entityKind = header.tryGetEntityKind(); if (linkGeneratorOrNull == null && entityKind != null) { linkGeneratorOrNull = new CellListenerAndLinkGenerator(entityKind, header); - registerListenerAndLinkGenerator(header.getId(), linkGeneratorOrNull); + registerListenerAndLinkGenerator(columnId, linkGeneratorOrNull); } // TypedTableGridColumnDefinitionUI<T> definition = @@ -353,6 +352,11 @@ public abstract class TypedTableGrid<T extends ISerializable> return columnUIDefinitions; } + protected ICellListenerAndLinkGenerator<T> tryGetCellListenerAndLinkGenerator(String columnId) + { + return listenerLinkGenerators.get(columnId); + } + /** * Translates a column ID to a key used to get title of the column from a dictionary. This * method can be overridden by subclasses. diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/MaterialReplicaFeatureSummaryViewer.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/MaterialReplicaFeatureSummaryViewer.java index c4691c73689..bc5dd275e04 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/MaterialReplicaFeatureSummaryViewer.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/MaterialReplicaFeatureSummaryViewer.java @@ -69,7 +69,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellImage; */ public class MaterialReplicaFeatureSummaryViewer { - private static final int IMAGE_SIZE_PX = 400; + private static final int WELL_IMAGES_SIZE_PX = 400; public static void openTab(IViewContext<IScreeningClientServiceAsync> screeningViewContext, String experimentPermId, MaterialIdentifier materialIdentifier) @@ -214,7 +214,6 @@ public class MaterialReplicaFeatureSummaryViewer } } - // TODO 2011-04-12, Tomasz Pylak: correct the height private Widget createImagesViewer(List<? extends WellImage> images) { if (images.isEmpty()) @@ -234,18 +233,20 @@ public class MaterialReplicaFeatureSummaryViewer LayoutContainer imagePanel = new LayoutContainer(); imagePanel.setScrollMode(Scroll.AUTOY); imagePanel.setLayout(new RowLayout()); + int imageSize = Math.min(100, WELL_IMAGES_SIZE_PX / images.size()); for (WellImage wellImage : images) { - Widget imageViewer = createImageViewer(wellImage, channelChooser); + Widget imageViewer = createImageViewer(wellImage, channelChooser, imageSize); imagePanel.add(imageViewer); } - double imagePanelHeight = - Math.min(IMAGE_SIZE_PX * 2.5, images.size() * IMAGE_SIZE_PX + 100); + // TODO 2011-04-12, Tomasz Pylak: correct the height + double imagePanelHeight = Math.min(500, images.size() * imageSize + 150); panel.add(imagePanel, new RowData(1, imagePanelHeight)); return panel; } - private Widget createImageViewer(final WellImage image, ChannelChooserPanel channelChooser) + private Widget createImageViewer(final WellImage image, ChannelChooserPanel channelChooser, + final int imageSize) { assert image.tryGetImageDataset() != null; final ISimpleChanneledViewerFactory viewerFactory = new ISimpleChanneledViewerFactory() @@ -253,7 +254,7 @@ public class MaterialReplicaFeatureSummaryViewer public Widget create(List<String> channels) { return WellContentDialog.createImageViewerForChannel(screeningViewContext, - image, IMAGE_SIZE_PX, IMAGE_SIZE_PX, channels); + image, imageSize, imageSize, channels); } }; ChannelWidgetWithListener widgetWithListener = new ChannelWidgetWithListener(viewerFactory); @@ -277,7 +278,8 @@ public class MaterialReplicaFeatureSummaryViewer final IDisposableComponent gridComponent = MaterialReplicaFeatureSummaryGrid.create(screeningViewContext, new TechId( experiment), new TechId(material)); - panel.add(gridComponent.getComponent(), new RowData(1, LayoutUtils.ONE_PAGE_GRID_HEIGHT_PX)); + // TODO 2011-04-13, Tomasz Pylak: fix height + panel.add(gridComponent.getComponent(), new RowData(1, 400)); screeningViewContext.getService().listWellImages(new TechId(material.getId()), new TechId(experiment.getId()), new ImagesFoundCallback(panel)); diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/WellSearchGrid.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/WellSearchGrid.java index 7ec4de82a1f..7e3081465e0 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/WellSearchGrid.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/client/application/detailviewers/WellSearchGrid.java @@ -16,8 +16,6 @@ package ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.detailviewers; -import static ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.grids.WellSearchGridColumnIds.WELL; - import java.util.Arrays; import java.util.Date; import java.util.List; @@ -68,9 +66,12 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.TechId; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Experiment; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ISerializableComparable; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.IScreeningClientServiceAsync; +import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.ClientPluginFactory; import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.Dict; import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.DisplayTypeIDGenerator; import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.ScreeningDisplayTypeIDGenerator; @@ -78,6 +79,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.d import ch.systemsx.cisd.openbis.plugin.screening.client.web.client.application.ui.columns.specific.ScreeningLinkExtractor; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.DatasetImagesReference; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.DatasetReference; +import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.ExperimentReference; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.ImageDatasetParameters; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellContent; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellSearchCriteria; @@ -296,6 +298,87 @@ public class WellSearchGrid extends TypedTableGrid<WellContent> return new DefaultChannelState(viewContext, displayTypeId); } + @Override + protected ICellListenerAndLinkGenerator<WellContent> tryGetCellListenerAndLinkGenerator( + String columnId) + { + final String wellMaterialPropertyTypeCode = + WellSearchGridColumnIds.tryExtractWellMaterialPropertyCode(columnId); + if (wellMaterialPropertyTypeCode != null) + { + ICellListenerAndLinkGenerator<WellContent> listenerLinkGenerator = + createMaterialLinkGenerator(wellMaterialPropertyTypeCode); + registerLinkClickListenerFor(columnId, listenerLinkGenerator); + return listenerLinkGenerator; + } else + { + return super.tryGetCellListenerAndLinkGenerator(columnId); + } + } + + private ICellListenerAndLinkGenerator<WellContent> createMaterialLinkGenerator( + final String wellMaterialPropertyTypeCode) + { + return new ICellListenerAndLinkGenerator<WellContent>() + { + public String tryGetLink(WellContent wellContent, ISerializableComparable value) + { + Material material = tryGetMaterial(wellContent, wellMaterialPropertyTypeCode); + if (material == null) + { + return null; + } + return tryCreateMaterialDetailsLink(wellContent, material); + } + + public void handle(TableModelRowWithObject<WellContent> row, + boolean specialKeyPressed) + { + WellContent wellContent = row.getObjectOrNull(); + if (wellContent == null) + { + return; + } + Material material = tryGetMaterial(wellContent, wellMaterialPropertyTypeCode); + if (material == null) + { + return; + } + openImagingMaterialViewer(wellContent, material); + } + + }; + } + + private static Material tryGetMaterial(WellContent entity, String wellMaterialPropertyTypeCode) + { + for (IEntityProperty wellMaterialProperty : entity.getMaterialTypeProperties()) + { + if (wellMaterialProperty.getPropertyType().getCode() + .equalsIgnoreCase(wellMaterialPropertyTypeCode)) + { + return wellMaterialProperty.getMaterial(); + } + } + return null; + } + + private static String tryCreateMaterialDetailsLink(WellContent wellContent, Material material) + { + String experimentIdentifier = wellContent.getExperiment().getExperimentIdentifier(); + return ScreeningLinkExtractor.tryCreateMaterialDetailsLink(material, experimentIdentifier); + } + + private void openImagingMaterialViewer(WellContent wellContent, Material material) + { + ExperimentReference experiment = wellContent.getExperiment(); + ExperimentSearchCriteria experimentCriteria = + ExperimentSearchCriteria.createExperiment(experiment.getId(), + experiment.getPermId(), experiment.getExperimentIdentifier()); + + ClientPluginFactory.openImagingMaterialViewer(material, experimentCriteria, viewContext); + } + private void linkExperiment() { registerListenerAndLinkGenerator(WellSearchGridColumnIds.EXPERIMENT, @@ -623,7 +706,7 @@ public class WellSearchGrid extends TypedTableGrid<WellContent> @Override protected void listTableRows( DefaultResultSetConfig<String, TableModelRowWithObject<WellContent>> resultSetConfig, - AsyncCallback<TypedTableResultSet<WellContent>> callback) + final AsyncCallback<TypedTableResultSet<WellContent>> callback) { assert experimentCriteriaOrNull != null : "experiment not specified"; @@ -643,7 +726,7 @@ public class WellSearchGrid extends TypedTableGrid<WellContent> @Override protected List<String> getColumnIdsOfFilters() { - return Arrays.asList(WELL); + return Arrays.asList(WellSearchGridColumnIds.PLATE, WellSearchGridColumnIds.WELL); } } diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/WellContentProvider.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/WellContentProvider.java index 0ed2908ff86..f630198743f 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/WellContentProvider.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/client/web/server/WellContentProvider.java @@ -46,6 +46,7 @@ import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.FeatureValue; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.NamedFeatureVector; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellContent; import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.WellSearchCriteria; +import ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.grids.WellSearchGridColumnIds; /** * @author Franz-Josef Elmer @@ -54,8 +55,6 @@ public class WellContentProvider extends AbstractTableModelProvider<WellContent> { static final String WELL_PROPERTY_ID_PREFIX = "WELL_PROPERTY-"; - static final String MATERIAL_PROPERTY_GROUP = "MATERIAL_PROPERTY-"; - static final String WELL_CONTENT_FEATURE_VECTOR_GROUP = "WELL_CONTENT_FEATURE_VECTOR-"; private final IScreeningServer server; @@ -132,8 +131,8 @@ public class WellContentProvider extends AbstractTableModelProvider<WellContent> private IColumnGroup getMaterialColumnGroup(TypedTableModelBuilder<WellContent> builder, IEntityProperty materialProperty) { - return builder.columnGroup(MATERIAL_PROPERTY_GROUP - + materialProperty.getPropertyType().getSimpleCode() + "-"); + return builder.columnGroup(WellSearchGridColumnIds + .getWellMaterialColumnGroupPrefix(materialProperty)); } /** @@ -142,8 +141,8 @@ public class WellContentProvider extends AbstractTableModelProvider<WellContent> private IColumnGroup getMaterialPropsColumnGroup(TypedTableModelBuilder<WellContent> builder, IEntityProperty materialProperty) { - return builder.columnGroup(MATERIAL_PROPERTY_GROUP + "PROP-" - + materialProperty.getPropertyType().getSimpleCode() + "-"); + return builder.columnGroup(WellSearchGridColumnIds + .getWellMaterialPropertyColumnGroupPrefix(materialProperty)); } private void addRow(TypedTableModelBuilder<WellContent> builder, WellContent well, @@ -272,7 +271,6 @@ public class WellContentProvider extends AbstractTableModelProvider<WellContent> return new ArrayList<IEntityProperty>(orderedMaterialProps.values()); } - private void sortByMaterialCodes(List<WellContent> wells, final List<IEntityProperty> materialPropsOrder) { diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/MaterialAllReplicasFeatureVectors.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/MaterialAllReplicasFeatureVectors.java index 74c1c1bde81..83bc6d9c710 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/MaterialAllReplicasFeatureVectors.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/MaterialAllReplicasFeatureVectors.java @@ -11,6 +11,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ServiceVersionHolder; * * @author Tomasz Pylak */ +// TODO 2011-04-13, Tomasz Pylak: move to the server side public class MaterialAllReplicasFeatureVectors implements ISerializable { private static final long serialVersionUID = ServiceVersionHolder.VERSION; diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/grids/WellSearchGridColumnIds.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/grids/WellSearchGridColumnIds.java index 861b4c5ed18..275c24240d6 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/grids/WellSearchGridColumnIds.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/shared/basic/dto/grids/WellSearchGridColumnIds.java @@ -16,20 +16,63 @@ package ch.systemsx.cisd.openbis.plugin.screening.shared.basic.dto.grids; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IEntityProperty; /** * Fixed column IDs for well search grid. - * + * * @author Franz-Josef Elmer */ -public class WellSearchGridColumnIds +public class WellSearchGridColumnIds { public static final String EXPERIMENT = "experiment"; + public static final String PLATE = "PLATE"; + public static final String WELL = "WELL"; + public static final String IMAGE_DATA_SET = "IMAGE_DATA_SET"; + public static final String IMAGE_ANALYSIS_DATA_SET = "IMAGE_ANALYSIS_DATA_SET"; + public static final String FILE_FORMAT_TYPE = "file_format_type"; + public static final String WELL_IMAGES = "WELL_IMAGES"; + private static final String MATERIAL_PROPERTY_GROUP = "MATERIAL_PROPERTY-"; + + private static final String PROPERTY_CODE_MARKER = "$$$"; + + public static String tryExtractWellMaterialPropertyCode(String columnId) + { + // TODO 2011-04-13, Tomasz Pylak: unify with TypedTableModelBuilder.getColumnId() + String userPropertyPrefix = "USER-"; + String propertyPrefix = PROPERTY_CODE_MARKER + userPropertyPrefix; + int ix = columnId.indexOf(propertyPrefix); + if (ix != -1) + { + return columnId.substring(ix + propertyPrefix.length()); + } else + { + return null; + } + } + + /** id of the well column of material type */ + public static String getWellMaterialColumnGroupPrefix(IEntityProperty wellMaterialProperty) + { + return MATERIAL_PROPERTY_GROUP + wellMaterialProperty.getPropertyType().getSimpleCode() + + "-" + PROPERTY_CODE_MARKER; + } + + /** + * id of the column which contains properties of the material (which itself is a property of the + * well) + */ + public static String getWellMaterialPropertyColumnGroupPrefix(IEntityProperty materialProperty) + { + return MATERIAL_PROPERTY_GROUP + "PROP-" + PROPERTY_CODE_MARKER + + materialProperty.getPropertyType().getSimpleCode() + "-"; + } + } -- GitLab