From d8eb7d2b9a639e5189c893827c821dc6f59a8b27 Mon Sep 17 00:00:00 2001
From: Nick Draper <nick.draper@stfc.ac.uk>
Date: Mon, 20 Jan 2020 16:33:33 +0000
Subject: [PATCH] Changed double click to show data if only one bin

Also included code suggestion
I've not removed the ability to plot from the Show data table because:
1. If they try that hard they deserve an empty graph
2. I can't work out how.
---
 .../workbench/workbench/plugins/workspacewidget.py        | 8 ++++++--
 .../src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp  | 8 ++++----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/qt/applications/workbench/workbench/plugins/workspacewidget.py b/qt/applications/workbench/workbench/plugins/workspacewidget.py
index ce06d4eae68..7160a9c282b 100644
--- a/qt/applications/workbench/workbench/plugins/workspacewidget.py
+++ b/qt/applications/workbench/workbench/plugins/workspacewidget.py
@@ -203,13 +203,17 @@ class WorkspaceWidget(PluginWidget):
         CreateDetectorTable(InputWorkspace=ws)
 
     def _action_double_click_workspace(self, name):
+        ws = self._ads.retrieve(name)
         try:
             # if this is a table workspace (or peaks workspace),
             # then it can't be plotted automatically, so the data is shown instead
-            TableWorkspaceDisplay.supports(self._ads.retrieve(name))
+            TableWorkspaceDisplay.supports(ws)
             self._do_show_data([name])
         except ValueError:
-            plot_from_names([name], errors=False, overplot=False, show_colorfill_btn=True)
+            if ws.blocksize() > 1:
+                plot_from_names([name], errors=False, overplot=False, show_colorfill_btn=True)
+            else:
+                self._do_show_data([name])
 
     def refresh_workspaces(self):
         self.workspacewidget.refreshWorkspaces()
diff --git a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp
index 2412bd803db..0c0ca8bbfc3 100644
--- a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp
+++ b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidgetSimple.cpp
@@ -121,10 +121,10 @@ void WorkspaceTreeWidgetSimple::popupContextMenu() {
           }
         }
       }
-      m_plotSpectrum->setEnabled(multipleBins);
-      m_overplotSpectrum->setEnabled(multipleBins);
-      m_plotSpectrumWithErrs->setEnabled(multipleBins);
-      m_overplotSpectrumWithErrs->setEnabled(multipleBins);
+      //disable the actions created so far if only one bin
+      for (auto action : plotSubMenu->actions()) {
+        action->setEnabled(multipleBins);
+      }
 
       plotSubMenu->addSeparator();
       plotSubMenu->addAction(m_plotColorfill);
-- 
GitLab