From 488b0101fd0aab40c379dba8ac447458f01b4fe9 Mon Sep 17 00:00:00 2001
From: buczekp <buczekp>
Date: Tue, 9 Mar 2010 17:14:53 +0000
Subject: [PATCH] [LMS-1415] optionally select sample type and space

SVN: 15088
---
 .../framework/ComponentProvider.java          | 15 ++++-
 .../locator/BrowserLocatorResolver.java       | 17 +++---
 .../application/ui/GroupSelectionWidget.java  | 31 ++++++----
 .../ui/experiment/ProjectSelectionWidget.java |  9 +--
 .../field/VocabularyTermSelectionWidget.java  |  5 --
 .../ui/grid/AbstractEntityBrowserGrid.java    |  2 +-
 ...EntityTypePropertyTypeSelectionWidget.java |  7 +--
 .../ui/sample/SampleBrowserGrid.java          | 18 +++++-
 .../ui/sample/SampleBrowserToolbar.java       | 18 ++++--
 .../ui/sample/SampleTypeSelectionWidget.java  | 58 ++++++++++++++++++-
 .../bo/datasetlister/DatasetLister.java       |  1 -
 .../generic/shared/basic/GridRowModel.java    |  2 +-
 .../application/module/QueryBrowserGrid.java  |  4 +-
 13 files changed, 135 insertions(+), 52 deletions(-)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/ComponentProvider.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/ComponentProvider.java
index 6bf0de22454..9842122f4a7 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/ComponentProvider.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/ComponentProvider.java
@@ -102,13 +102,18 @@ public final class ComponentProvider
                 isCloseConfirmationNeeded);
     }
 
-    public final ITabItemFactory getSampleBrowser()
+    public ITabItemFactory getSampleBrowser(final String initialGroupOrNull,
+            final String initialSampleTypeOrNull)
     {
         return new ITabItemFactory()
             {
                 public ITabItem create()
                 {
-                    IDisposableComponent browser = SampleBrowserGrid.create(viewContext);
+                    System.err.println(initialGroupOrNull + " " + initialSampleTypeOrNull);
+
+                    IDisposableComponent browser =
+                            SampleBrowserGrid.create(viewContext, initialGroupOrNull,
+                                    initialSampleTypeOrNull);
                     return createTab(Dict.SAMPLE_BROWSER, browser);
                 }
 
@@ -124,6 +129,11 @@ public final class ComponentProvider
             };
     }
 
+    public final ITabItemFactory getSampleBrowser()
+    {
+        return getSampleBrowser(null, null);
+    }
+
     public final ITabItemFactory getMaterialBrowser()
     {
         return new ITabItemFactory()
@@ -783,4 +793,5 @@ public final class ComponentProvider
     {
         this.mainTabPanelOrNull = mainTabPanel;
     }
+
 }
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/BrowserLocatorResolver.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/BrowserLocatorResolver.java
index ccecc4c708f..867c9dfb29e 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/BrowserLocatorResolver.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/locator/BrowserLocatorResolver.java
@@ -21,6 +21,8 @@ public class BrowserLocatorResolver extends AbstractViewLocatorResolver
 
     public final static String TYPE_PARAMETER_KEY = "type";
 
+    public final static String GROUP_PARAMETER_KEY = "space";
+
     public final static String PROJECT_PARAMETER_KEY = "project";
 
     public BrowserLocatorResolver(IViewContext<ICommonClientServiceAsync> viewContext)
@@ -32,15 +34,16 @@ public class BrowserLocatorResolver extends AbstractViewLocatorResolver
     public void resolve(ViewLocator locator) throws UserFailureException
     {
         EntityKind entityKind = getEntityKind(locator);
+        final String entityTypeOrNull = locator.getParameters().get(TYPE_PARAMETER_KEY);
         switch (entityKind)
         {
             case EXPERIMENT:
                 final String projectOrNull = locator.getParameters().get(PROJECT_PARAMETER_KEY);
-                final String experimentTypeOrNull = locator.getParameters().get(TYPE_PARAMETER_KEY);
-                openExperimentBrowser(projectOrNull, experimentTypeOrNull);
+                openExperimentBrowser(projectOrNull, entityTypeOrNull);
                 break;
             case SAMPLE:
-                openSampleBrowser();
+                final String groupOrNull = locator.getParameters().get(GROUP_PARAMETER_KEY);
+                openSampleBrowser(groupOrNull, entityTypeOrNull);
                 break;
             case MATERIAL:
                 openMaterialBrowser();
@@ -58,15 +61,15 @@ public class BrowserLocatorResolver extends AbstractViewLocatorResolver
                 initialProjectOrNull, initialExperimentTypeOrNull));
     }
 
-    private void openSampleBrowser()
+    private void openSampleBrowser(String initialGroupOrNull, String initialSampleTypeOrNull)
     {
-        // TODO select sample type and group
-        DispatcherHelper.dispatchNaviEvent(new ComponentProvider(viewContext).getSampleBrowser());
+        DispatcherHelper.dispatchNaviEvent(new ComponentProvider(viewContext).getSampleBrowser(
+                initialGroupOrNull, initialSampleTypeOrNull));
     }
 
     private void openMaterialBrowser()
     {
-        // TODO select material type
+        // TODO 2010-03-09, Piotr Buczek: optionally select material type
         DispatcherHelper.dispatchNaviEvent(new ComponentProvider(viewContext).getMaterialBrowser());
     }
 
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/GroupSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/GroupSelectionWidget.java
index 2c48c778191..be5425fee72 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/GroupSelectionWidget.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/GroupSelectionWidget.java
@@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui;
 import java.util.List;
 
 import com.extjs.gxt.ui.client.store.ListStore;
+import com.extjs.gxt.ui.client.widget.MessageBox;
 import com.extjs.gxt.ui.client.widget.form.ComboBox;
 
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback;
@@ -86,7 +87,6 @@ public class GroupSelectionWidget extends DropDownList<GroupModel, Space>
         this.addShared = addShared;
         this.addAll = addAll;
         this.initialGroupOrNull = initialGroupCodeOrNull;
-
     }
 
     /**
@@ -135,16 +135,23 @@ public class GroupSelectionWidget extends DropDownList<GroupModel, Space>
                 groupStore.add(new GroupModel(createAllSpaces()));
             }
             groupStore.add(convertItems(result.getList().extractOriginalObjects()));
+            dataLoaded = true;
             if (groupStore.getCount() > 0)
             {
                 setEmptyText(viewContext.getMessage(Dict.COMBO_BOX_CHOOSE, viewContext
                         .getMessage(Dict.GROUP)));
                 setReadOnly(false);
-                final int homeGroupIndex = getHomeGroupIndex(groupStore);
-                if (homeGroupIndex > -1)
+                if (initialGroupOrNull != null)
+                {
+                    selectGroupAndUpdateOriginal(initialGroupOrNull);
+                } else
                 {
-                    setValue(groupStore.getAt(homeGroupIndex));
-                    setOriginalValue(getValue());
+                    final int homeGroupIndex = getHomeGroupIndex(groupStore);
+                    if (homeGroupIndex > -1)
+                    {
+                        setValue(groupStore.getAt(homeGroupIndex));
+                        setOriginalValue(getValue());
+                    }
                 }
             } else
             {
@@ -152,8 +159,6 @@ public class GroupSelectionWidget extends DropDownList<GroupModel, Space>
                         .getMessage(Dict.GROUPS)));
                 setReadOnly(true);
             }
-            dataLoaded = true;
-            selectGroupAndUpdateOriginal(initialGroupOrNull);
         }
 
         int getHomeGroupIndex(ListStore<GroupModel> groupStore)
@@ -180,9 +185,15 @@ public class GroupSelectionWidget extends DropDownList<GroupModel, Space>
         initialGroupOrNull = group;
         if (dataLoaded && initialGroupOrNull != null)
         {
-            GWTUtils.setSelectedItem(GroupSelectionWidget.this, ModelDataPropertyNames.CODE,
-                    initialGroupOrNull);
-            setOriginalValue(getValue());
+            try
+            {
+                GWTUtils.setSelectedItem(GroupSelectionWidget.this, ModelDataPropertyNames.CODE,
+                        initialGroupOrNull);
+            } catch (IllegalArgumentException ex)
+            {
+                MessageBox.alert("Error", "Space '" + group + "' doesn't exist.", null);
+            }
+            updateOriginalValue();
         }
     }
 
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionWidget.java
index 327fc64ed9c..6b38644c626 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionWidget.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/experiment/ProjectSelectionWidget.java
@@ -25,15 +25,15 @@ import com.extjs.gxt.ui.client.widget.form.ComboBox;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback;
 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.model.NonHierarchicalBaseModelData;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.ModelDataPropertyNames;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.NonHierarchicalBaseModelData;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.DropDownList;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.GWTUtils;
 import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DefaultResultSetConfig;
 import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ResultSet;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind;
-import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind.ObjectKind;
 
 /**
@@ -155,11 +155,6 @@ public final class ProjectSelectionWidget extends
         }
     }
 
-    public void updateOriginalValue()
-    {
-        setOriginalValue(getValue());
-    }
-
     @Override
     protected List<ProjectComboModel> convertItems(List<Project> projects)
     {
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java
index 215e78b6020..aebcbbf5467 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/field/VocabularyTermSelectionWidget.java
@@ -142,11 +142,6 @@ public class VocabularyTermSelectionWidget extends
         GWTUtils.setSelectedItem(this, ModelDataPropertyNames.CODE, termCode);
     }
 
-    public void updateOriginalValue()
-    {
-        setOriginalValue(getValue());
-    }
-
     private class ListTermsCallback extends VocabularyTermSelectionWidget.ListItemsCallback
     {
 
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityBrowserGrid.java
index 8ce76a428a7..4d2b6f9c391 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityBrowserGrid.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/grid/AbstractEntityBrowserGrid.java
@@ -165,7 +165,7 @@ public abstract class AbstractEntityBrowserGrid<T extends IEntityPropertiesHolde
         Boolean refreshColumnsNeeded = updateCriteria();
         if (refreshColumnsNeeded != null && refreshColumnsNeeded.booleanValue())
         {
-        	// TODO layout of grid with filters is invoked second time here 
+            // TODO 2010-03-09, Piotr Buczek: layout of grid with filters is invoked second time
             super.recreateColumnModelAndRefreshColumnsWithFilters();
         }
     }
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/EntityTypePropertyTypeSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/EntityTypePropertyTypeSelectionWidget.java
index 982692e6fa3..7d340e82916 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/EntityTypePropertyTypeSelectionWidget.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/property_type/EntityTypePropertyTypeSelectionWidget.java
@@ -25,8 +25,8 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAs
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback;
 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.model.NonHierarchicalBaseModelData;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.ModelDataPropertyNames;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.model.NonHierarchicalBaseModelData;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.renderer.PropertyTypeRenderer;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.DropDownList;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.GWTUtils;
@@ -122,11 +122,6 @@ public final class EntityTypePropertyTypeSelectionWidget
         GWTUtils.setSelectedItem(this, ModelDataPropertyNames.CODE, termCode);
     }
 
-    public void updateOriginalValue()
-    {
-        setOriginalValue(getValue());
-    }
-
     public final Long getSelectedEntityTypePropertyTypeOrdinal()
     {
         final EntityTypePropertyTypeComboModel selectedItem = getValue();
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid.java
index 0172f7503c1..1cab35a7bc1 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserGrid.java
@@ -120,11 +120,16 @@ public class SampleBrowserGrid extends
         return browserGrid.asDisposableWithToolbar(toolbar);
     }
 
-    public static IDisposableComponent create(
-            final IViewContext<ICommonClientServiceAsync> viewContext)
+    /**
+     * Create a grid with a toolbar with no initial selection and optional initial selection of
+     * sample type and group.
+     */
+    public static IDisposableComponent create(IViewContext<ICommonClientServiceAsync> viewContext,
+            String initialGroupOrNull, String initialSampleTypeOrNull)
     {
         final SampleBrowserToolbar toolbar =
-                new SampleBrowserToolbar(viewContext, true, true, false);
+                new SampleBrowserToolbar(viewContext, true, true, false, initialGroupOrNull,
+                        initialSampleTypeOrNull);
         ISampleCriteriaProvider criteriaProvider = toolbar;
         final SampleBrowserGrid browserGrid =
                 new SampleBrowserGrid(viewContext, criteriaProvider, GRID_ID, BROWSER_ID, false,
@@ -134,6 +139,13 @@ public class SampleBrowserGrid extends
         return browserGrid.asDisposableWithToolbar(toolbar);
     }
 
+    /** Create a grid with a toolbar with no initial selection. */
+    public static IDisposableComponent create(
+            final IViewContext<ICommonClientServiceAsync> viewContext)
+    {
+        return create(viewContext, null, null);
+    }
+
     public static IDisposableComponent createGridForContainerSamples(
             final IViewContext<ICommonClientServiceAsync> viewContext,
             final TechId containerSampleId, final String gridId, final SampleType sampleType,
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserToolbar.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserToolbar.java
index 580508c58ec..414128c1de7 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserToolbar.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleBrowserToolbar.java
@@ -41,10 +41,10 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction;
 import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ListSampleDisplayCriteria;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind;
-import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ListSampleCriteria;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.PropertyType;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.SampleType;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind.ObjectKind;
 
 /**
@@ -71,15 +71,25 @@ final class SampleBrowserToolbar extends ToolBar implements ISampleCriteriaProvi
     private final boolean excludeWithoutExperiment;
 
     public SampleBrowserToolbar(final IViewContext<?> viewContext, final boolean addShared,
-            boolean addAll, final boolean excludeWithoutExperiment)
+            boolean addAll, final boolean excludeWithoutExperiment, String initialGroupOrNull,
+            String initialSampleTypeOrNull)
     {
         this.viewContext = viewContext;
         this.excludeWithoutExperiment = excludeWithoutExperiment;
-        selectSampleTypeCombo = new SampleTypeSelectionWidget(viewContext, ID, true, true, false);
-        selectGroupCombo = new GroupSelectionWidget(viewContext, ID, addShared, addAll);
+        selectSampleTypeCombo =
+                new SampleTypeSelectionWidget(viewContext, ID, true, true, false,
+                        initialSampleTypeOrNull);
+        selectGroupCombo =
+                new GroupSelectionWidget(viewContext, ID, addShared, addAll, initialGroupOrNull);
         display();
     }
 
+    public SampleBrowserToolbar(final IViewContext<?> viewContext, final boolean addShared,
+            boolean addAll, final boolean excludeWithoutExperiment)
+    {
+        this(viewContext, addShared, addAll, excludeWithoutExperiment, null, null);
+    }
+
     public ListSampleDisplayCriteria tryGetCriteria()
     {
         final SampleType selectedType = tryGetSelectedSampleType();
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleTypeSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleTypeSelectionWidget.java
index 8c08e6a4fce..8d362af469c 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleTypeSelectionWidget.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/sample/SampleTypeSelectionWidget.java
@@ -21,6 +21,7 @@ import static ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModifica
 
 import java.util.List;
 
+import com.extjs.gxt.ui.client.widget.MessageBox;
 import com.extjs.gxt.ui.client.widget.form.ComboBox;
 
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback;
@@ -52,8 +53,11 @@ public final class SampleTypeSelectionWidget extends DropDownList<SampleTypeMode
 
     private final boolean withTypeInFile;
 
+    private final String initialCodeOrNull;
+
     public SampleTypeSelectionWidget(final IViewContext<?> viewContext, final String idSuffix,
-            final boolean onlyListable, final boolean withAll, final boolean withTypeInFile)
+            final boolean onlyListable, final boolean withAll, final boolean withTypeInFile,
+            final String initialCodeOrNull)
     {
         super(viewContext, SUFFIX + idSuffix, Dict.SAMPLE_TYPE, ModelDataPropertyNames.CODE,
                 "sample type", "sample types");
@@ -61,11 +65,18 @@ public final class SampleTypeSelectionWidget extends DropDownList<SampleTypeMode
         this.onlyListable = onlyListable;
         this.withAll = withAll;
         this.withTypeInFile = withTypeInFile;
-        setAutoSelectFirst(withAll);
+        this.initialCodeOrNull = initialCodeOrNull;
+        setAutoSelectFirst(withAll && initialCodeOrNull == null);
         setTemplate(GWTUtils.getTooltipTemplate(ModelDataPropertyNames.CODE,
                 ModelDataPropertyNames.TOOLTIP));
     }
 
+    public SampleTypeSelectionWidget(final IViewContext<?> viewContext, final String idSuffix,
+            final boolean onlyListable, final boolean withAll, final boolean withTypeInFile)
+    {
+        this(viewContext, idSuffix, onlyListable, withAll, withTypeInFile, null);
+    }
+
     public SampleTypeSelectionWidget(final IViewContext<?> viewContext, final String idSuffix,
             final boolean onlyListable)
     {
@@ -108,7 +119,8 @@ public final class SampleTypeSelectionWidget extends DropDownList<SampleTypeMode
     @Override
     protected void loadData(AbstractAsyncCallback<List<SampleType>> callback)
     {
-        viewContext.getCommonService().listSampleTypes(callback);
+        viewContext.getCommonService().listSampleTypes(new ListSampleTypesCallback(viewContext));
+        callback.ignore();
     }
 
     public DatabaseModificationKind[] getRelevantModifications()
@@ -118,4 +130,44 @@ public final class SampleTypeSelectionWidget extends DropDownList<SampleTypeMode
                     createOrDelete(ObjectKind.PROPERTY_TYPE_ASSIGNMENT),
                     edit(ObjectKind.PROPERTY_TYPE_ASSIGNMENT) };
     }
+
+    // 
+    // initial value support
+    //
+
+    private void selectInitialValue()
+    {
+        if (initialCodeOrNull != null)
+        {
+            trySelectByCode(initialCodeOrNull);
+            updateOriginalValue();
+        }
+    }
+
+    private void trySelectByCode(String code)
+    {
+        try
+        {
+            GWTUtils.setSelectedItem(this, ModelDataPropertyNames.CODE, code);
+        } catch (IllegalArgumentException ex)
+        {
+            MessageBox.alert("Error", "Sample Type '" + code + "' doesn't exist.", null);
+        }
+    }
+
+    private class ListSampleTypesCallback extends SampleTypeSelectionWidget.ListItemsCallback
+    {
+
+        protected ListSampleTypesCallback(IViewContext<?> viewContext)
+        {
+            super(viewContext);
+        }
+
+        @Override
+        public void process(List<SampleType> result)
+        {
+            super.process(result);
+            selectInitialValue();
+        }
+    }
 }
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java
index eb94fcb63a3..70ac7f59eee 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java
@@ -321,7 +321,6 @@ public class DatasetLister implements IDatasetLister
     private ExternalData createPrimaryDataset(DatasetRecord record)
     {
         ExternalData dataset = createBasicDataset(record);
-        // TODO data set type
         dataset.setId(record.id);
         dataset.setComplete(resolve(record.is_complete));
         dataset.setDataProducerCode(escapeHtml(record.data_producer_code));
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/GridRowModel.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/GridRowModel.java
index a2c941d30bf..ab4d77e7c63 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/GridRowModel.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/GridRowModel.java
@@ -33,7 +33,7 @@ public class GridRowModel<T> implements IsSerializable
 {
     private T originalObject;
 
-    // TODO Now that we use GWT 2.0 it should be possible to use map here.
+    // TODO 2010-03-09, Piotr Buczek: Now that we use GWT 2.0 it should be possible to use map here.
     // We would like to have a Map field, but we cannot do it because of a bug in
     // displaying serialization warnings in GWT 1.5. It was fixed in GWT 1.6
     private List<GridCustomColumnValue> calculatedColumnValues;
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/client/web/client/application/module/QueryBrowserGrid.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/client/web/client/application/module/QueryBrowserGrid.java
index df3ed1a5a62..211a6912573 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/client/web/client/application/module/QueryBrowserGrid.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/query/client/web/client/application/module/QueryBrowserGrid.java
@@ -38,6 +38,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.dto.TableExportCriteri
 import ch.systemsx.cisd.openbis.generic.shared.basic.IColumnDefinition;
 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.DatabaseModificationKind.ObjectKind;
 import ch.systemsx.cisd.openbis.plugin.query.client.web.client.IQueryClientServiceAsync;
 import ch.systemsx.cisd.openbis.plugin.query.client.web.client.application.Constants;
 import ch.systemsx.cisd.openbis.plugin.query.client.web.client.application.Dict;
@@ -191,7 +192,6 @@ public class QueryBrowserGrid extends AbstractSimpleBrowserGrid<QueryExpression>
 
     public DatabaseModificationKind[] getRelevantModifications()
     {
-        // TODO Auto-generated method stub
-        return new DatabaseModificationKind[] {};
+        return DatabaseModificationKind.any(ObjectKind.QUERY);
     }
 }
-- 
GitLab