From 5b9d8d019e7e7692c9215702d68e1c4a9cb9bd6f Mon Sep 17 00:00:00 2001
From: buczekp <buczekp>
Date: Tue, 1 Mar 2011 18:06:51 +0000
Subject: [PATCH] [LMS-2083] improved UI with DataSetProcessingMenu

SVN: 20186
---
 .../application/ui/data/ComputationData.java  |  12 +-
 .../ui/data/DataSetComputeUtils.java          |  19 +--
 .../ui/data/DataSetProcessingMenu.java        |  83 +++++++++++++
 .../ui/data/PerformComputationDialog.java     |  19 +--
 .../data/ProcessingPluginSelectionWidget.java | 113 ------------------
 .../dataset/AbstractDataSetsSection.java      | 106 +++++++++-------
 .../sample/SampleDataSetsSection.java         |   5 +-
 7 files changed, 173 insertions(+), 184 deletions(-)
 create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetProcessingMenu.java
 delete mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/ProcessingPluginSelectionWidget.java

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/ComputationData.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/ComputationData.java
index 97497faee6e..ff13463a256 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/ComputationData.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/ComputationData.java
@@ -20,30 +20,30 @@ import java.util.List;
 
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.AbstractExternalDataGrid.SelectedAndDisplayedItems;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.SelectedOrAllDataSetsRadioProvider.ISelectedDataSetsProvider;
-import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataStoreServiceKind;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData;
 
 class ComputationData implements ISelectedDataSetsProvider
 {
-    private final DataStoreServiceKind dssTaskKind;
+    private final DatastoreServiceDescription service;
 
     private final IComputationAction computationAction;
 
     private final SelectedAndDisplayedItems selectedAndDisplayedItems;
 
-    public ComputationData(DataStoreServiceKind dssTaskKind,
+    public ComputationData(DatastoreServiceDescription service,
             IComputationAction computationAction,
             SelectedAndDisplayedItems selectedAndDisplayedItems)
     {
         super();
-        this.dssTaskKind = dssTaskKind;
+        this.service = service;
         this.computationAction = computationAction;
         this.selectedAndDisplayedItems = selectedAndDisplayedItems;
     }
 
-    public DataStoreServiceKind getDssTaskKind()
+    public DatastoreServiceDescription getService()
     {
-        return dssTaskKind;
+        return service;
     }
 
     public IComputationAction getComputationAction()
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetComputeUtils.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetComputeUtils.java
index d997992fcad..39889715f6c 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetComputeUtils.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetComputeUtils.java
@@ -24,8 +24,8 @@ import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewConte
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.AbstractExternalDataGrid.SelectedAndDisplayedItems;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.report.ReportGeneratedCallback.IOnReportComponentGeneratedAction;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedActionWithResult;
 import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DisplayedOrSelectedDatasetCriteria;
-import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataStoreServiceKind;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription;
 
 /**
@@ -36,27 +36,29 @@ public class DataSetComputeUtils
 
     public static IDelegatedAction createComputeAction(
             final IViewContext<ICommonClientServiceAsync> viewContext,
-            final SelectedAndDisplayedItems selectedAndDisplayedItems,
-            final DatastoreServiceDescription service, final DataStoreServiceKind dssTaskKind,
+            final IDelegatedActionWithResult<SelectedAndDisplayedItems> selectedDataSetsGetter,
+            final DatastoreServiceDescription service,
             final IOnReportComponentGeneratedAction reportGeneratedAction)
     {
         return new IDelegatedAction()
             {
                 public void execute()
                 {
+                    final SelectedAndDisplayedItems selectedAndDisplayedItems =
+                            selectedDataSetsGetter.execute();
                     final IComputationAction computationAction =
                             createComputationAction(viewContext, selectedAndDisplayedItems,
-                                    dssTaskKind, reportGeneratedAction);
+                                    reportGeneratedAction);
                     final ComputationData data =
-                            new ComputationData(dssTaskKind, computationAction,
+                            new ComputationData(service, computationAction,
                                     selectedAndDisplayedItems);
                     createPerformComputationDialog(data).show();
                 }
 
                 private Window createPerformComputationDialog(ComputationData data)
                 {
-                    final String title = "Perform " + dssTaskKind.getDescription();
-                    return new PerformComputationDialog(viewContext, data, title, service);
+                    final String title = "Perform " + service.getLabel();
+                    return new PerformComputationDialog(viewContext, data, title);
                 }
             };
     }
@@ -64,7 +66,6 @@ public class DataSetComputeUtils
     private static IComputationAction createComputationAction(
             final IViewContext<ICommonClientServiceAsync> viewContext,
             final SelectedAndDisplayedItems selectedAndDisplayedItems,
-            final DataStoreServiceKind dssTaskKind,
             final IOnReportComponentGeneratedAction reportGeneratedAction)
     {
         return new IComputationAction()
@@ -73,7 +74,7 @@ public class DataSetComputeUtils
                 {
                     DisplayedOrSelectedDatasetCriteria criteria =
                             selectedAndDisplayedItems.createCriteria(computeOnSelected);
-                    switch (dssTaskKind)
+                    switch (service.getServiceKind())
                     {
                         case QUERIES:
                             DataSetReportGenerator.generateAndInvoke(viewContext, service,
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetProcessingMenu.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetProcessingMenu.java
new file mode 100644
index 00000000000..f7edd59d75d
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/DataSetProcessingMenu.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2009 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.data;
+
+import java.util.List;
+
+import com.extjs.gxt.ui.client.widget.menu.Menu;
+
+import ch.systemsx.cisd.openbis.generic.client.web.client.ICommonClientServiceAsync;
+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.menu.ActionMenu;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.menu.IActionMenuItem;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.AbstractExternalDataGrid.SelectedAndDisplayedItems;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedAction;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedActionWithResult;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IMessageProvider;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.TextToolItem;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription;
+
+/**
+ * 'Actions' menu for Data Sets.
+ * 
+ * @author Piotr Buczek
+ */
+public class DataSetProcessingMenu extends TextToolItem
+{
+
+    private final IViewContext<ICommonClientServiceAsync> viewContext;
+
+    private final IDelegatedActionWithResult<SelectedAndDisplayedItems> selectedDataSetsGetter;
+
+    public DataSetProcessingMenu(IViewContext<ICommonClientServiceAsync> viewContext,
+            IDelegatedActionWithResult<SelectedAndDisplayedItems> selectedDataSetsGetter,
+            List<DatastoreServiceDescription> processingServices)
+    {
+        super(viewContext.getMessage(Dict.MENU_PROCESSING));
+        this.viewContext = viewContext;
+        this.selectedDataSetsGetter = selectedDataSetsGetter;
+
+        Menu submenu = new Menu();
+        for (DatastoreServiceDescription service : processingServices)
+        {
+            addMenuItem(submenu, service);
+        }
+        setMenu(submenu);
+    }
+
+    private final void addMenuItem(Menu submenu, final DatastoreServiceDescription service)
+    {
+        final IDelegatedAction menuItemAction =
+                DataSetComputeUtils.createComputeAction(viewContext, selectedDataSetsGetter,
+                        service, null);
+        final IActionMenuItem menuItemKind = new IActionMenuItem()
+            {
+                public String getMenuText(IMessageProvider messageProvider)
+                {
+                    return service.getLabel();
+                }
+
+                public String getMenuId()
+                {
+                    return service.getKey();
+                }
+            };
+        submenu.add(new ActionMenu(menuItemKind, viewContext, menuItemAction));
+    }
+
+}
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/PerformComputationDialog.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/PerformComputationDialog.java
index 2192a409f24..aa2ecd514be 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/PerformComputationDialog.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/PerformComputationDialog.java
@@ -62,16 +62,16 @@ class PerformComputationDialog extends AbstractDataConfirmationDialog<Computatio
 
     private final SelectedOrAllDataSetsRadioProvider radioProvider;
 
-    private final DatastoreServiceDescription selectedPlugin;
+    private final DatastoreServiceDescription pluginTask;
 
     private Html selectedDataSetTypesText;
 
     protected PerformComputationDialog(IViewContext<ICommonClientServiceAsync> viewContext,
-            ComputationData data, String title, DatastoreServiceDescription selectedPlugin)
+            ComputationData data, String title)
     {
         super(viewContext, data, title);
         this.viewContext = viewContext;
-        this.selectedPlugin = selectedPlugin;
+        this.pluginTask = data.getService();
         this.radioProvider = new SelectedOrAllDataSetsRadioProvider(data);
 
         this.dataStoreOrNull = tryGetSingleDatastore(data);
@@ -107,7 +107,7 @@ class PerformComputationDialog extends AbstractDataConfirmationDialog<Computatio
     protected String createMessage()
     {
         int size = data.getSelectedDataSets().size();
-        String computationName = selectedPlugin.getLabel();
+        String computationName = pluginTask.getLabel();
         if (size == 0)
         {
             final String msgIntroduction = viewContext.getMessage(Dict.NO_DATASETS_SELECTED);
@@ -134,12 +134,11 @@ class PerformComputationDialog extends AbstractDataConfirmationDialog<Computatio
     @Override
     protected boolean validate()
     {
-        final DatastoreServiceDescription selectedPluginTask = getSelectedPluginTask();
         final boolean computeOnSelected = getComputeOnSelected();
         if (computeOnSelected)
         {
             // show error message if plugin does not support all types of selected data sets
-            Set<String> supportedDataSetTypes = getSupportedDataSetTypes(selectedPluginTask);
+            Set<String> supportedDataSetTypes = getSupportedDataSetTypes(pluginTask);
             List<String> unsupportedDataSetTypes = new ArrayList<String>();
             for (String selectedDataSetType : selectedDataSetTypeCodes)
             {
@@ -162,9 +161,8 @@ class PerformComputationDialog extends AbstractDataConfirmationDialog<Computatio
     protected void executeConfirmedAction()
     {
         final IComputationAction computationAction = data.getComputationAction();
-        final DatastoreServiceDescription selectedPluginTask = getSelectedPluginTask();
         final boolean computeOnSelected = getComputeOnSelected();
-        computationAction.execute(selectedPluginTask, computeOnSelected);
+        computationAction.execute(pluginTask, computeOnSelected);
     }
 
     private Set<String> getSupportedDataSetTypes(DatastoreServiceDescription plugin)
@@ -172,11 +170,6 @@ class PerformComputationDialog extends AbstractDataConfirmationDialog<Computatio
         return new HashSet<String>(Arrays.asList(plugin.getDatasetTypeCodes()));
     }
 
-    private DatastoreServiceDescription getSelectedPluginTask()
-    {
-        return selectedPlugin;
-    }
-
     @Override
     protected void extendForm()
     {
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/ProcessingPluginSelectionWidget.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/ProcessingPluginSelectionWidget.java
deleted file mode 100644
index 7432176c7fa..00000000000
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/data/ProcessingPluginSelectionWidget.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright 2011 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.data;
-
-import java.util.List;
-
-import com.extjs.gxt.ui.client.event.Events;
-import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
-import com.extjs.gxt.ui.client.store.ListStore;
-import com.extjs.gxt.ui.client.util.Util;
-
-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.ModelDataPropertyNames;
-import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.DropDownList;
-import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.IDataRefreshCallback;
-import ch.systemsx.cisd.openbis.generic.shared.basic.IIdHolder;
-import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataStoreServiceKind;
-import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseModificationKind;
-import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription;
-
-/**
- * @author Piotr Buczek
- */
-public class ProcessingPluginSelectionWidget extends
-        DropDownList<DatastoreServiceDescriptionModel, DatastoreServiceDescription>
-{
-
-    private final IViewContext<?> viewContext;
-
-    public ProcessingPluginSelectionWidget(final IViewContext<?> viewContext,
-            final IIdHolder ownerIdOrNull)
-    {
-        super(
-                viewContext,
-                (((ownerIdOrNull != null) ? ownerIdOrNull.getId().toString() : "") + "_data-set_processing-plugins"),
-                Dict.BUTTON_PROCESS, ModelDataPropertyNames.LABEL, "action", "actions");
-        this.viewContext = viewContext;
-        addPostRefreshCallback(createHideOnNoServicesAction());
-    }
-
-    private IDataRefreshCallback createHideOnNoServicesAction()
-    {
-        return new IDataRefreshCallback()
-            {
-                public void postRefresh(boolean wasSuccessful)
-                {
-                    // hide combo box if there are no services
-                    final ListStore<DatastoreServiceDescriptionModel> modelsStore = getStore();
-                    if (modelsStore.getCount() > 0)
-                    {
-                        show();
-                    } else
-                    {
-                        hide();
-                    }
-                }
-            };
-    }
-
-    @Override
-    protected List<DatastoreServiceDescriptionModel> convertItems(
-            List<DatastoreServiceDescription> result)
-    {
-        List<DatastoreServiceDescriptionModel> models =
-                DatastoreServiceDescriptionModel.convert(result, null);
-        return models;
-    }
-
-    @Override
-    protected void loadData(AbstractAsyncCallback<List<DatastoreServiceDescription>> callback)
-    {
-        viewContext.getCommonService().listDataStoreServices(DataStoreServiceKind.PROCESSING,
-                callback);
-    }
-
-    public DatabaseModificationKind[] getRelevantModifications()
-    {
-        return new DatabaseModificationKind[0]; // don't update
-    }
-
-    @Override
-    public void setValue(DatastoreServiceDescriptionModel value)
-    {
-        // fire SelectionChange event on each combo box selection, even if selected item
-        // did't change, to refresh viewer
-        DatastoreServiceDescriptionModel oldValue = getValue();
-        super.setValue(value);
-        if (Util.equalWithNull(oldValue, value))
-        {
-            SelectionChangedEvent<DatastoreServiceDescriptionModel> se =
-                    new SelectionChangedEvent<DatastoreServiceDescriptionModel>(this,
-                            getSelection());
-            fireEvent(Events.SelectionChange, se);
-        }
-    }
-
-}
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/AbstractDataSetsSection.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/AbstractDataSetsSection.java
index 0165d77b222..8d7290997a0 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/AbstractDataSetsSection.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/dataset/AbstractDataSetsSection.java
@@ -16,24 +16,29 @@
 
 package ch.systemsx.cisd.openbis.plugin.generic.client.web.client.application.dataset;
 
+import java.util.List;
+
 import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
 import com.extjs.gxt.ui.client.event.SelectionChangedListener;
+import com.extjs.gxt.ui.client.widget.toolbar.SeparatorToolItem;
 
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.AbstractAsyncCallback;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.DisposableTabContent;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.IViewContext;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.framework.DisplayTypeIDGenerator;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.AbstractExternalDataGrid;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.AbstractExternalDataGrid.SelectedAndDisplayedItems;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.DataSetComputeUtils;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.DataSetProcessingMenu;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.DataSetReportGenerator;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.DatastoreServiceDescriptionModel;
-import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.ProcessingPluginSelectionWidget;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.ReportingPluginSelectionWidget;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.report.ReportGeneratedCallback.IOnReportComponentGeneratedAction;
-import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget.DropDownList;
+import ch.systemsx.cisd.openbis.generic.client.web.client.application.util.IDelegatedActionWithResult;
 import ch.systemsx.cisd.openbis.generic.client.web.client.dto.DisplayedOrSelectedDatasetCriteria;
 import ch.systemsx.cisd.openbis.generic.shared.basic.IIdHolder;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataStoreServiceKind;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescription;
 
 /**
@@ -41,9 +46,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatastoreServiceDescrip
  */
 public abstract class AbstractDataSetsSection extends DisposableTabContent
 {
-    protected final DropDownList<DatastoreServiceDescriptionModel, DatastoreServiceDescription> reportSelectionWidget;
-
-    protected final DropDownList<DatastoreServiceDescriptionModel, DatastoreServiceDescription> processingSelectionWidget;
+    protected final ReportingPluginSelectionWidget reportSelectionWidget;
 
     protected final IOnReportComponentGeneratedAction reportGeneratedAction;
 
@@ -54,8 +57,6 @@ public abstract class AbstractDataSetsSection extends DisposableTabContent
     {
         super(header, viewContext, ownerIdOrNull);
         this.reportSelectionWidget = new ReportingPluginSelectionWidget(viewContext, ownerIdOrNull);
-        this.processingSelectionWidget =
-                new ProcessingPluginSelectionWidget(viewContext, ownerIdOrNull);
         this.reportGeneratedAction = new IOnReportComponentGeneratedAction()
             {
                 public void execute(IDisposableComponent gridComponent)
@@ -68,23 +69,27 @@ public abstract class AbstractDataSetsSection extends DisposableTabContent
 
     protected abstract IDisposableComponent createDatasetBrowserComponent();
 
-    protected void initWidgets()
+    protected void initWidgets(AbstractExternalDataGrid browser)
     {
         getHeader().addTool(reportSelectionWidget);
-        getHeader().addTool(processingSelectionWidget);
+        if (viewContext.isSimpleMode() == false)
+        {
+            // processing plugins should be hidden in simple view mode
+            viewContext.getCommonService().listDataStoreServices(DataStoreServiceKind.PROCESSING,
+                    new LoadProcessingPluginsCallback(viewContext, browser));
+        }
     }
 
     @Override
     protected final IDisposableComponent createDisposableContent()
     {
-        initWidgets();
         metadataComponent = createDatasetBrowserComponent();
+        initWidgets(extractBrowser(metadataComponent));
 
-        SelectionChangedListener<DatastoreServiceDescriptionModel> serviceChangedListener =
-                createServiceSelectionChangedListener(viewContext, metadataComponent,
+        SelectionChangedListener<DatastoreServiceDescriptionModel> reportChangedListener =
+                createReportSelectionChangedListener(viewContext, metadataComponent,
                         reportGeneratedAction);
-        reportSelectionWidget.addSelectionChangedListener(serviceChangedListener);
-        processingSelectionWidget.addSelectionChangedListener(serviceChangedListener);
+        reportSelectionWidget.addSelectionChangedListener(reportChangedListener);
         return metadataComponent;
     }
 
@@ -112,12 +117,16 @@ public abstract class AbstractDataSetsSection extends DisposableTabContent
         metadataComponent.dispose(); // NOTE: second dispose on a grid does nothing
     }
 
-    private static SelectionChangedListener<DatastoreServiceDescriptionModel> createServiceSelectionChangedListener(
+    private static AbstractExternalDataGrid extractBrowser(IDisposableComponent metadataComponent)
+    {
+        return (AbstractExternalDataGrid) metadataComponent.getComponent();
+    }
+
+    private static SelectionChangedListener<DatastoreServiceDescriptionModel> createReportSelectionChangedListener(
             final IViewContext<?> viewContext, final IDisposableComponent metadataComponent,
             final IOnReportComponentGeneratedAction reportGeneratedAction)
     {
-        final AbstractExternalDataGrid browser =
-                (AbstractExternalDataGrid) metadataComponent.getComponent();
+        final AbstractExternalDataGrid browser = extractBrowser(metadataComponent);
         return new SelectionChangedListener<DatastoreServiceDescriptionModel>()
             {
 
@@ -135,54 +144,69 @@ public abstract class AbstractDataSetsSection extends DisposableTabContent
                             showMetadataView();
                         } else
                         {
-                            switch (service.getServiceKind())
-                            {
-                                case PROCESSING:
-                                    process(service);
-                                    break;
-                                case QUERIES:
-                                    showGeneratedReportComponentView(service);
-                                    break;
-                            }
+                            showGeneratedReport(service);
                         }
                     }
 
                 }
 
-                private void process(DatastoreServiceDescription service)
-                {
-                    SelectedAndDisplayedItems items =
-                            browser.getSelectedAndDisplayedItemsAction().execute();
-                    DataSetComputeUtils.createComputeAction(viewContext.getCommonViewContext(),
-                            items, service, service.getServiceKind(), reportGeneratedAction)
-                            .execute();
-                }
-
                 private void showMetadataView()
                 {
                     reportGeneratedAction.execute(metadataComponent);
                 }
 
-                private void showGeneratedReportComponentView(DatastoreServiceDescription service)
+                private void showGeneratedReport(DatastoreServiceDescription service)
                 {
-                    SelectedAndDisplayedItems items =
-                            browser.getSelectedAndDisplayedItemsAction().execute();
+                    assert service.getServiceKind() == DataStoreServiceKind.QUERIES;
+
+                    IDelegatedActionWithResult<SelectedAndDisplayedItems> selectedAndDisplayedItemsAction =
+                            browser.getSelectedAndDisplayedItemsAction();
 
                     if (browser.getSelectedItems().isEmpty())
                     {
-                        // when no data sets were selected perform query without asking
-                        DisplayedOrSelectedDatasetCriteria criteria = items.createCriteria(false);
+                        // when no data sets were selected perform query on all without asking
+                        DisplayedOrSelectedDatasetCriteria criteria =
+                                selectedAndDisplayedItemsAction.execute().createCriteria(false);
                         DataSetReportGenerator.generateAndInvoke(
                                 viewContext.getCommonViewContext(), service, criteria,
                                 reportGeneratedAction);
                     } else
                     {
                         DataSetComputeUtils.createComputeAction(viewContext.getCommonViewContext(),
-                                items, service, service.getServiceKind(), reportGeneratedAction)
+                                selectedAndDisplayedItemsAction, service, reportGeneratedAction)
                                 .execute();
                     }
                 }
+
             };
 
     }
+
+    public final class LoadProcessingPluginsCallback extends
+            AbstractAsyncCallback<List<DatastoreServiceDescription>>
+    {
+        private final AbstractExternalDataGrid browser;
+
+        public LoadProcessingPluginsCallback(final IViewContext<?> viewContext,
+                AbstractExternalDataGrid browser)
+        {
+            super(viewContext);
+            this.browser = browser;
+        }
+
+        @Override
+        protected void process(List<DatastoreServiceDescription> result)
+        {
+            if (result.isEmpty() == false)
+            {
+
+                DataSetProcessingMenu menu =
+                        new DataSetProcessingMenu(viewContext.getCommonViewContext(),
+                                browser.getSelectedAndDisplayedItemsAction(), result);
+                getHeader().addTool(new SeparatorToolItem());
+                getHeader().addTool(menu);
+            }
+        }
+    }
+
 }
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/SampleDataSetsSection.java b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/SampleDataSetsSection.java
index 0afa3811c45..7cc50968982 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/SampleDataSetsSection.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/plugin/generic/client/web/client/application/sample/SampleDataSetsSection.java
@@ -22,6 +22,7 @@ import com.extjs.gxt.ui.client.widget.form.CheckBox;
 
 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.ui.data.AbstractExternalDataGrid;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.DatastoreServiceDescriptionModel;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.data.ReportingPluginSelectionWidget;
 import ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.grid.IDisposableComponent;
@@ -52,7 +53,7 @@ public class SampleDataSetsSection extends AbstractDataSetsSection
     }
 
     @Override
-    protected void initWidgets()
+    protected void initWidgets(AbstractExternalDataGrid browser)
     {
         // first add check box
         getHeader().addTool(showOnlyDirectlyConnectedCheckBox);
@@ -80,7 +81,7 @@ public class SampleDataSetsSection extends AbstractDataSetsSection
                             }
                         }
                     });
-        super.initWidgets();
+        super.initWidgets(browser);
     }
 
     @Override
-- 
GitLab