14 #include "internal/org_mitk_gui_qt_application_Activator.h" 26 #include <QMessageBox> 61 this->setText(
"&Close Project...");
62 this->setToolTip(
"Close Project will remove all data objects from the application. This will free up the memory that is used by the data.");
63 this->connect(
this, SIGNAL(triggered(
bool)),
this, SLOT(
Run()));
70 ctkPluginContext* context = mitk::PluginActivator::GetContext();
80 MITK_WARN <<
"IDataStorageService service not available. Unable to close project.";
81 context->ungetService(dsRef);
86 if (dataStorageRef.
IsNull())
93 if (dataStorage.IsNull())
95 MITK_WARN <<
"No data storage available. Cannot close project.";
100 if(dataStorageRef->IsDefault() &&
107 QString msg =
"Are you sure that you want to close the current project (%1)?\nThis will remove all data objects.";
108 if (QMessageBox::question(
nullptr,
"Remove all data?", msg.arg(dataStorageRef->GetLabel()),
109 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
115 mitk::DataStorage::SetOfObjects::ConstPointer nodesToRemove = dataStorage->GetAll();
116 dataStorage->Remove(nodesToRemove);
123 QList<berry::IEditorReference::Pointer> dsEditors =
126 if (!dsEditors.empty())
128 QList<berry::IEditorReference::Pointer> editorsToClose = dsEditors;
129 m_Window->
GetActivePage()->CloseEditors(editorsToClose,
false);
132 catch (std::exception& e)
134 MITK_ERROR <<
"Exception caught during closing project: " << e.what();
135 QMessageBox::warning(
nullptr,
"Error", QString(
"An error occurred during Close Project: %1").arg(e.what()));
virtual IDataStorageReference::Pointer GetDefaultDataStorage() const =0
virtual IDataStorageReference::Pointer GetActiveDataStorage() const =0
static const int MATCH_INPUT
static Pointer New(const mitk::NodePredicateBase *_arg)
static Pointer New(const char *_arg)
QmitkCloseProjectAction(berry::SmartPointer< berry::IWorkbenchWindow > window)
virtual bool RemoveDataStorageReference(IDataStorageReference::Pointer dataStorageRef)=0
SmartPointer< IWorkbenchPage > GetActivePage() const override=0
ObjectType * GetPointer() const