Skip to content

Commit

Permalink
Move ICAT menu items to use non-modal dialogs.
Browse files Browse the repository at this point in the history
Refs #9756
  • Loading branch information
martyngigg committed Jun 30, 2014
1 parent 4e8e959 commit dacfef1
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 34 deletions.
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/CatalogManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ namespace Mantid
void destroyCatalog(const std::string &sessionID);
/// Obtains a list of the current active catalog sessions.
std::vector<CatalogSession_sptr> getActiveSessions();
/// Returns the number of active sessions
size_t numberActiveSessions() const;

private:
/// These methods are required to create a singleton.
Expand Down
6 changes: 6 additions & 0 deletions Code/Mantid/Framework/API/src/CatalogManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,11 @@ namespace Mantid

return sessions;
}

/// @returns An unsigned value indicating the number of active sessions
size_t CatalogManagerImpl::numberActiveSessions() const
{
return m_activeCatalogs.size();
}
}
}
30 changes: 19 additions & 11 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,11 @@
#include "MantidKernel/Logger.h"
#include "MantidKernel/MantidVersion.h"

#include "MantidAPI/WorkspaceFactory.h"
#include "MantidAPI/AlgorithmFactory.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/CatalogManager.h"
#include "MantidAPI/ITableWorkspace.h"
#include "MantidAPI/WorkspaceFactory.h"

#include "MantidQtAPI/ScriptRepositoryView.h"

Expand Down Expand Up @@ -1287,7 +1288,8 @@ void ApplicationWindow::initMainMenu()

icat = new QMenu(this);
icat->setObjectName("CatalogMenu");
icat->addAction(actionCatalogLogin);//Login menu item
connect(icat, SIGNAL(aboutToShow()), this, SLOT(populateCatalogLoginMenu()));

disableActions();
}

Expand Down Expand Up @@ -3455,9 +3457,9 @@ void ApplicationWindow::convertTableToMatrixWorkspace()
if(auto *mt = dynamic_cast<MantidTable*>(t))
{
mt = convertTableToTableWorkspace(t);
QMap<QString,QString> params;
QHash<QString,QString> params;
params["InputWorkspace"] = QString::fromStdString(mt->getWorkspaceName());
mantidUI->executeAlgorithmDlg("ConvertTableToMatrixWorkspace",params);
mantidUI->showAlgorithmDialog(QString("ConvertTableToMatrixWorkspace"),params);
}
}

Expand Down Expand Up @@ -6179,9 +6181,9 @@ void ApplicationWindow::loadDataFile()
}
else if(mantidUI)
{ // Run Load algorithm on file
QMap<QString,QString> params;
QHash<QString,QString> params;
params["Filename"] = fn;
mantidUI->executeAlgorithmDlg("Load",params);
mantidUI->showAlgorithmDialog(QString("Load"),params);
}
}
}
Expand Down Expand Up @@ -17469,17 +17471,23 @@ void ApplicationWindow::panOnPlot()
g->enablePanningMagnifier();
}
/// Handler for ICat Login Menu
void ApplicationWindow::CatalogLogin()
void ApplicationWindow::populateCatalogLoginMenu()
{
// Executes the catalog login algorithm, and returns true if user can login.
if (MantidQt::MantidWidgets::CatalogHelper().isValidCatalogLogin())
icat->clear();
icat->addAction(actionCatalogLogin);
if(Mantid::API::CatalogManager::Instance().numberActiveSessions() > 0)
{
icat->addAction(actionCatalogSearch);
icat->addAction(actionCatalogPublish);
icat->addAction(actionCatalogLogout);
}
}

void ApplicationWindow::CatalogLogin()
{
MantidQt::MantidWidgets::CatalogHelper().showLoginDialog();
}

void ApplicationWindow::CatalogSearch()
{
if (catalogSearch == NULL || catalogSearch)
Expand All @@ -17497,7 +17505,7 @@ void ApplicationWindow::CatalogSearch()

void ApplicationWindow::CatalogPublish()
{
MantidQt::MantidWidgets::CatalogHelper().catalogPublishDialog();
MantidQt::MantidWidgets::CatalogHelper().showPublishDialog();
}

void ApplicationWindow::CatalogLogout()
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/MantidPlot/src/ApplicationWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,8 @@ public slots:
/// for zooming the selected graph using mouse drag tool
void panOnPlot();

/// Handler for catalog login.
void populateCatalogLoginMenu();
/// Handler for catalog login.
void CatalogLogin();
/// Handler for catalog search.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ namespace MantidQt
const std::map<std::string, std::string> &inputFields);
/// Creates a time_t value from an input date ("23/06/2003") for comparison.
time_t getTimevalue(const std::string& inputDate);
/// Executes the catalog login algorithm and returns true if user can login.
bool isValidCatalogLogin();
/// Executes the catalog login algorithm dialog, returning immediately
void showLoginDialog();
/// Create a publishing dialog.
void catalogPublishDialog();
void showPublishDialog();

private:
/// Creates an algorithm with the name provided.
Expand Down
34 changes: 14 additions & 20 deletions Code/Mantid/MantidQt/MantidWidgets/src/CatalogHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,33 +251,27 @@ namespace MantidQt
* Opens auto-generated dialog, and executes the catalog login algorithm.
* Returns true if login was a success.
*/
bool CatalogHelper::isValidCatalogLogin()
void CatalogHelper::showLoginDialog()
{
auto catalogAlgorithm = createCatalogAlgorithm("CatalogLogin");
API::InterfaceManager interface;
auto loginDialog = interface.createDialog(catalogAlgorithm.get());

if(loginDialog->exec() == QDialog::Accepted)
{
executeAsynchronously(catalogAlgorithm);
if (catalogAlgorithm->isExecuted()) return true;
}
return false;
API::InterfaceManager interfaceMgr;
auto dlg = interfaceMgr.createDialogFromName("CatalogLogin");
dlg->setModal(false);
dlg->show();
dlg->raise();
dlg->activateWindow();
}

/**
* Creates a publishing dialog GUI and runs the publishing algorithm when "Run" is pressed.
*/
void CatalogHelper::catalogPublishDialog()
void CatalogHelper::showPublishDialog()
{
auto catalogAlgorithm = createCatalogAlgorithm("CatalogPublish");
API::InterfaceManager interface;
auto publishDialog = interface.createDialog(catalogAlgorithm.get());

if(publishDialog->exec() == QDialog::Accepted)
{
executeAsynchronously(catalogAlgorithm);
}
API::InterfaceManager interfaceMgr;
auto dlg = interfaceMgr.createDialogFromName("CatalogPublish");
dlg->setModal(false);
dlg->show();
dlg->raise();
dlg->activateWindow();
}

/**
Expand Down

0 comments on commit dacfef1

Please sign in to comment.