From 06c5742c03d6830734268ea1ca9f18ce64fa0169 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Mon, 13 Dec 2010 13:57:04 +0000 Subject: [PATCH] LMS-1783 replace SampleBrowserGrid by SampleBrowserGrid2. Bugs in parent linking fixed. SVN: 19107 --- .../ui/field/SampleChooserButton.java | 27 +++++++------- .../ui/field/SampleChooserField.java | 17 +++++---- .../ui/grid/AbstractBrowserGrid.java | 2 +- .../ui/sample/SampleBrowserGrid2.java | 37 ++++++++++--------- .../ui/sample/SampleSearchHitGrid.java | 31 +++++++++------- .../web/client/dto/TypedTableResultSet.java | 2 +- .../web/server/resultset/SampleProvider.java | 4 ++ ...AbstractGenericSampleRegisterEditForm.java | 7 ++-- 8 files changed, 71 insertions(+), 56 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/SampleChooserButton.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/SampleChooserButton.java index 925fdb1c9f4..6c06eb8521d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/SampleChooserButton.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/SampleChooserButton.java @@ -30,15 +30,16 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.Dict; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.SampleTypeDisplayID; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.DisposableEntityChooser; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.sample.SampleBrowserGrid; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.sample.SampleBrowserGrid2; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; /** * ` A button for selecting a sample from a list. * * @author Piotr Buczek */ -public class SampleChooserButton extends Button implements IChosenEntitySetter<Sample> +public class SampleChooserButton extends Button implements IChosenEntitySetter<TableModelRowWithObject<Sample>> { public interface SampleChooserButtonAdaptor { @@ -50,8 +51,8 @@ public class SampleChooserButton extends Button implements IChosenEntitySetter<S String getValue(); } - private final Set<IChosenEntityListener<Sample>> listeners = - new LinkedHashSet<IChosenEntityListener<Sample>>(); + private final Set<IChosenEntityListener<TableModelRowWithObject<Sample>>> listeners = + new LinkedHashSet<IChosenEntityListener<TableModelRowWithObject<Sample>>>(); /** * Creates a text field with the additional browse button which allow to choose a sample from @@ -121,23 +122,23 @@ public class SampleChooserButton extends Button implements IChosenEntitySetter<S } private static void browse(final IViewContext<ICommonClientServiceAsync> viewContext, - final IChosenEntitySetter<Sample> chooserSampleSetter, final boolean addShared, + final IChosenEntitySetter<TableModelRowWithObject<Sample>> chooserSampleSetter, final boolean addShared, boolean addAll, final boolean excludeWithoutExperiment, SampleTypeDisplayID sampleTypeDisplayID) { - DisposableEntityChooser<Sample> browser = - SampleBrowserGrid.createChooser(viewContext, addShared, addAll, + DisposableEntityChooser<TableModelRowWithObject<Sample>> browser = + SampleBrowserGrid2.createChooser(viewContext, addShared, addAll, excludeWithoutExperiment, sampleTypeDisplayID); String title = viewContext.getMessage(Dict.TITLE_CHOOSE_SAMPLE); - new EntityChooserDialog<Sample>(browser, chooserSampleSetter, title, viewContext).show(); + new EntityChooserDialog<TableModelRowWithObject<Sample>>(browser, chooserSampleSetter, title, viewContext).show(); } // ------------------ // @Override - public String renderEntity(Sample entityOrNull) + public String renderEntity(TableModelRowWithObject<Sample> entityOrNull) { - return entityOrNull.getIdentifier(); + return entityOrNull.getObjectOrNull().getIdentifier(); } private SampleChooserButton(final IViewContext<ICommonClientServiceAsync> viewContext, @@ -146,13 +147,13 @@ public class SampleChooserButton extends Button implements IChosenEntitySetter<S super(buttonText); } - public void setChosenEntity(Sample entityOrNull) + public void setChosenEntity(TableModelRowWithObject<Sample> entityOrNull) { if (entityOrNull != null) { setValue(renderEntity(entityOrNull)); } - for (IChosenEntityListener<Sample> listener : listeners) + for (IChosenEntityListener<TableModelRowWithObject<Sample>> listener : listeners) { listener.entityChosen(entityOrNull); } @@ -170,7 +171,7 @@ public class SampleChooserButton extends Button implements IChosenEntitySetter<S this.value = value; } - public void addChosenEntityListener(IChosenEntityListener<Sample> listener) + public void addChosenEntityListener(IChosenEntityListener<TableModelRowWithObject<Sample>> listener) { listeners.add(listener); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/SampleChooserField.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/SampleChooserField.java index 6bb385e3c8e..be142ff7e08 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/SampleChooserField.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/SampleChooserField.java @@ -24,16 +24,17 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.Dict; import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext; import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.SampleTypeDisplayID; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.DisposableEntityChooser; -import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.sample.SampleBrowserGrid; +import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.sample.SampleBrowserGrid2; import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.FieldUtil; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; /** * A field for selecting a sample from a list or by specifying sample identifier. * * @author Piotr Buczek */ -public class SampleChooserField extends ChosenEntitySetter<Sample> +public class SampleChooserField extends ChosenEntitySetter<TableModelRowWithObject<Sample>> { public interface SampleChooserFieldAdaptor { @@ -124,23 +125,23 @@ public class SampleChooserField extends ChosenEntitySetter<Sample> } private static void browse(final IViewContext<ICommonClientServiceAsync> viewContext, - final ChosenEntitySetter<Sample> chosenSampleField, final boolean addShared, + final ChosenEntitySetter<TableModelRowWithObject<Sample>> chosenSampleField, final boolean addShared, boolean addAll, final boolean excludeWithoutExperiment, SampleTypeDisplayID sampleTypeDisplayID) { - DisposableEntityChooser<Sample> browser = - SampleBrowserGrid.createChooser(viewContext, addShared, addAll, + DisposableEntityChooser<TableModelRowWithObject<Sample>> browser = + SampleBrowserGrid2.createChooser(viewContext, addShared, addAll, excludeWithoutExperiment, sampleTypeDisplayID); String title = viewContext.getMessage(Dict.TITLE_CHOOSE_SAMPLE); - new EntityChooserDialog<Sample>(browser, chosenSampleField, title, viewContext).show(); + new EntityChooserDialog<TableModelRowWithObject<Sample>>(browser, chosenSampleField, title, viewContext).show(); } // ------------------ @Override - public String renderEntity(Sample entityOrNull) + public String renderEntity(TableModelRowWithObject<Sample> entityOrNull) { - return entityOrNull.getIdentifier(); + return entityOrNull.getObjectOrNull().getIdentifier(); } private SampleChooserField(boolean mandatory, String initialValueOrNull, diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java index dacad2f786f..8600473c471 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractBrowserGrid.java @@ -1405,7 +1405,7 @@ public abstract class AbstractBrowserGrid<T/* Entity */, M extends BaseEntityMod return new MultilineStringCellRenderer(); } - protected final GridCellRenderer<BaseEntityModel<?>> createInternalLinkCellRenderer() + protected GridCellRenderer<BaseEntityModel<?>> createInternalLinkCellRenderer() { return LinkRenderer.createLinkRenderer(); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid2.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid2.java index a111af77a0c..43ff972c908 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid2.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid2.java @@ -314,9 +314,6 @@ public class SampleBrowserGrid2 extends TypedTableGrid<Sample> } - // property types used in the previous refresh operation or null if it has not occurred yet - private List<PropertyType> previousPropertyTypes; - // provides property types which will be used to build property columns in the grid and // criteria to filter samples private final ISampleCriteriaProvider propertyTypesAndCriteriaProvider; @@ -415,17 +412,25 @@ public class SampleBrowserGrid2 extends TypedTableGrid<Sample> public void handle(TableModelRowWithObject<Sample> rowItem, boolean specialKeyPressed) { - showEntityInformationHolderViewer(rowItem.getObjectOrNull().getGeneratedFrom(), false, - specialKeyPressed); + Sample parent = getParentOrNull(rowItem.getObjectOrNull()); + if (parent != null) + { + showEntityInformationHolderViewer(parent, false, specialKeyPressed); + } } public String tryGetLink(Sample entity, ISerializableComparable comparableValue) + { + Sample parent = getParentOrNull(entity); + return LinkExtractor.tryExtract(parent); + } + + private Sample getParentOrNull(Sample entity) { if (entity.getParents().size() == 1) { - Sample parent = entity.getGeneratedFrom(); - return LinkExtractor.tryExtract(parent); + return entity.getGeneratedFrom(); } return null; } @@ -448,15 +453,19 @@ public class SampleBrowserGrid2 extends TypedTableGrid<Sample> ISerializableComparable comparableValue) { Sample container = entity.getContainer(); - if (container == null) - { - return null; - } return LinkExtractor.tryExtract(container); } }); } + + + @Override + protected GridCellRenderer<BaseEntityModel<?>> createInternalLinkCellRenderer() + { + return LinkRenderer.createLinkRenderer(true); + } + @Override protected String translateColumnIdToDictionaryKey(String columnID) { @@ -696,12 +705,6 @@ public class SampleBrowserGrid2 extends TypedTableGrid<Sample> .getCommonViewContext()).getSampleRegistration(experimentContext)); } } - @Override - protected void refresh() - { - super.refresh(); - previousPropertyTypes = propertyTypesAndCriteriaProvider.tryGetPropertyTypes(); - } @Override protected void showEntityViewer(TableModelRowWithObject<Sample> row, boolean editMode, boolean inBackground) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleSearchHitGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleSearchHitGrid.java index 2aefd88b5b2..cd8a5ba49a5 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleSearchHitGrid.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleSearchHitGrid.java @@ -22,6 +22,7 @@ import java.util.List; import com.extjs.gxt.ui.client.event.ButtonEvent; import com.extjs.gxt.ui.client.event.SelectionListener; import com.extjs.gxt.ui.client.widget.button.Button; +import com.google.gwt.user.client.rpc.AsyncCallback; import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync; import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback; @@ -36,19 +37,19 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.search. import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.search.IDetailedSearchHitGrid; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DefaultResultSetConfig; import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ListSampleDisplayCriteria; -import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSet; +import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TypedTableResultSet; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DetailedSearchCriteria; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityKind; -import ch.systemsx.cisd.openbis.generic.shared.basic.dto.EntityType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; /** * Grid with detailed sample search results. * * @author Piotr Buczek */ -public class SampleSearchHitGrid extends SampleBrowserGrid implements IDetailedSearchHitGrid +public class SampleSearchHitGrid extends SampleBrowserGrid2 implements IDetailedSearchHitGrid { // browser consists of the grid and the paging toolbar public static final String SEARCH_BROWSER_ID = GenericConstants.ID_PREFIX @@ -114,7 +115,11 @@ public class SampleSearchHitGrid extends SampleBrowserGrid implements IDetailedS @Override public void componentSelected(ButtonEvent ce) { - showRelatedDataSets(viewContext, SampleSearchHitGrid.this); + // TODO, 2010-12-13, FJE, show related data sets isn't easy because + // TableModelRowWithObject doesn't implement IEntityInformationHolder. + // Changing the code is relatively easy but the method showRelatedDataSets() + // is also used by MatchingEntitiesPanel. +// showRelatedDataSets(viewContext, SampleSearchHitGrid.this); } }); addButton(showRelatedDatasetsButton); @@ -151,16 +156,16 @@ public class SampleSearchHitGrid extends SampleBrowserGrid implements IDetailedS } @Override - protected EntityType tryToGetEntityType() + protected void listTableRows( + DefaultResultSetConfig<String, TableModelRowWithObject<Sample>> resultSetConfig, + AsyncCallback<TypedTableResultSet<Sample>> callback) { - return null; + if (callback instanceof AbstractAsyncCallback) + { + AbstractAsyncCallback<TypedTableResultSet<Sample>> asc = (AbstractAsyncCallback<TypedTableResultSet<Sample>>) callback; + asc.addOnSuccessAction(new ShowResultSetCutInfo<TypedTableResultSet<Sample>>(viewContext)); + } + super.listTableRows(resultSetConfig, callback); } - @Override - protected void listEntities(DefaultResultSetConfig<String, Sample> resultSetConfig, - AbstractAsyncCallback<ResultSet<Sample>> callback) - { - callback.addOnSuccessAction(new ShowResultSetCutInfo<ResultSet<Sample>>(viewContext)); - super.listEntities(resultSetConfig, callback); - } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/TypedTableResultSet.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/TypedTableResultSet.java index 8a4bf7b0e1a..c2e23a9a8d7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/TypedTableResultSet.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/dto/TypedTableResultSet.java @@ -26,7 +26,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject * @author Franz-Josef Elmer */ @DoNotEscape -public class TypedTableResultSet<T extends ISerializable> implements IsSerializable +public class TypedTableResultSet<T extends ISerializable> implements IsSerializable, IResultSetHolder<TableModelRowWithObject<T>> { private ResultSet<TableModelRowWithObject<T>> resultSet; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/SampleProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/SampleProvider.java index 2b55d7bba88..f29dc1ca453 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/SampleProvider.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/server/resultset/SampleProvider.java @@ -113,6 +113,10 @@ public class SampleProvider extends AbstractCommonTableModelProvider<Sample> { Set<Sample> parents = sample.getParents(); int parentsSize = parents.size(); + if (parentsSize == 1) + { + return sample.getGeneratedFrom().getIdentifier(); + } StringBuilder builder = new StringBuilder(); int counter = 0; for (Sample parent : parents) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/AbstractGenericSampleRegisterEditForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/AbstractGenericSampleRegisterEditForm.java index 40ce4fc70f0..3931ace716d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/AbstractGenericSampleRegisterEditForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/AbstractGenericSampleRegisterEditForm.java @@ -57,6 +57,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleTypePropertyType; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space; +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModelRowWithObject; import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.IGenericClientServiceAsync; import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.application.AbstractGenericEntityRegistrationForm; import ch.systemsx.cisd.openbis.plugin.generic.client.web.client.application.experiment.PropertiesEditor; @@ -299,13 +300,13 @@ abstract public class AbstractGenericSampleRegisterEditForm extends .withSuffix(getSampleTypeCode())); parentsArea = new ParentSamplesArea(viewContext, getId()); SampleChooserButton parentChooserButton = parentButton.getChooserButton(); - parentChooserButton.addChosenEntityListener(new IChosenEntityListener<Sample>() + parentChooserButton.addChosenEntityListener(new IChosenEntityListener<TableModelRowWithObject<Sample>>() { - public void entityChosen(Sample entity) + public void entityChosen(TableModelRowWithObject<Sample> entity) { if (entity != null) { - String sampleIdentifier = entity.getIdentifier(); + String sampleIdentifier = entity.getObjectOrNull().getIdentifier(); parentsArea.appendItem(sampleIdentifier); } } -- GitLab