From e24817b43783d90bb42f77994ffb7098919a2114 Mon Sep 17 00:00:00 2001
From: izabel <izabel>
Date: Mon, 5 Oct 2009 09:07:14 +0000
Subject: [PATCH] [LMS-1202] refresh filter parameter fields

SVN: 12835
---
 .../client/application/ui/filter/FilterToolbar.java  |  9 +++++++++
 .../client/application/ui/widget/DropDownList.java   | 12 ++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/filter/FilterToolbar.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/filter/FilterToolbar.java
index 1164dbc0039..b3ea172fb96 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/filter/FilterToolbar.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/filter/FilterToolbar.java
@@ -28,6 +28,7 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewConte
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.IDatabaseModificationObserver;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisplayTypeIDProvider;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.PagingColumnFilter;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.IDataRefreshCallback;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction;
 import ch.systemsx.cisd.openbis.generic.client.web.client.dto.CustomFilterInfo;
 import ch.systemsx.cisd.openbis.generic.client.web.client.dto.ParameterWithValue;
@@ -91,6 +92,14 @@ public class FilterToolbar<T> extends ToolBar implements IDatabaseModificationOb
                 }
 
             });
+        filterSelectionWidget.addPostRefreshCallback(new IDataRefreshCallback()
+            {
+                public void postRefresh(boolean wasSuccessful)
+                {
+                    updateFilterFields();
+                    apply();
+                }
+            });
         applyTool.addSelectionListener(new SelectionListener<ComponentEvent>()
             {
                 @Override
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/DropDownList.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/DropDownList.java
index e076f0873e2..6c2d59802dd 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/DropDownList.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/DropDownList.java
@@ -72,6 +72,8 @@ abstract public class DropDownList<M extends ModelData, E> extends ComboBox<M> i
 
     public String callbackIdOrNull;
 
+    private final List<IDataRefreshCallback> dataRefreshCallbacks;
+
     public DropDownList(final IViewContext<?> viewContext, String idSuffix, String labelDictCode,
             String displayField, String chooseSuffix, String nothingFoundSuffix)
     {
@@ -92,6 +94,7 @@ abstract public class DropDownList<M extends ModelData, E> extends ComboBox<M> i
         this.mandatory = mandatory;
         this.reloadWhenRendering = reloadWhenRendering;
         this.viewContextOrNull = viewContextOrNull;
+        this.dataRefreshCallbacks = new ArrayList<IDataRefreshCallback>();
 
         setId(createId(idSuffix));
         setEnabled(true);
@@ -222,6 +225,10 @@ abstract public class DropDownList<M extends ModelData, E> extends ComboBox<M> i
         {
             List<M> convertedItems = convertItems(result);
             updateStore(convertedItems);
+            for (IDataRefreshCallback c : dataRefreshCallbacks)
+            {
+                c.postRefresh(true);
+            }
         }
 
         @Override
@@ -435,4 +442,9 @@ abstract public class DropDownList<M extends ModelData, E> extends ComboBox<M> i
         }
     }
 
+    public void addPostRefreshCallback(IDataRefreshCallback callback)
+    {
+        dataRefreshCallbacks.add(callback);
+    }
+
 }
-- 
GitLab