18 #include "internal/org_mitk_gui_qt_application_Activator.h"
30 #include <QMessageBox>
65 this->setText(
"&Close Project...");
66 this->setToolTip(
"Close Project will remove all data objects from the application. This will free up the memory that is used by the data.");
67 this->connect(
this, SIGNAL(triggered(
bool)),
this, SLOT(
Run()));
74 ctkPluginContext* context = mitk::PluginActivator::GetContext();
84 MITK_WARN <<
"IDataStorageService service not available. Unable to close project.";
85 context->ungetService(dsRef);
90 if (dataStorageRef.
IsNull())
97 if (dataStorage.IsNull())
99 MITK_WARN <<
"No data storage available. Cannot close project.";
104 if(dataStorageRef->IsDefault() &&
111 QString msg =
"Are you sure that you want to close the current project (%1)?\nThis will remove all data objects.";
112 if (QMessageBox::question(NULL,
"Remove all data?", msg.arg(dataStorageRef->GetLabel()),
113 QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes)
120 dataStorage->Remove(nodesToRemove);
127 QList<berry::IEditorReference::Pointer> dsEditors =
130 if (!dsEditors.empty())
132 QList<berry::IEditorReference::Pointer> editorsToClose = dsEditors;
133 m_Window->
GetActivePage()->CloseEditors(editorsToClose,
false);
136 catch (std::exception& e)
138 MITK_ERROR <<
"Exception caught during closing project: " << e.what();
139 QMessageBox::warning(NULL,
"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
virtual SmartPointer< IWorkbenchPage > GetActivePage() const override=0
itk::SmartPointer< const Self > ConstPointer
static Pointer New(const mitk::NodePredicateBase *_arg)
static Pointer New(const char *_arg)
QmitkCloseProjectAction(berry::SmartPointer< berry::IWorkbenchWindow > window)
ObjectType * GetPointer() const
virtual bool RemoveDataStorageReference(IDataStorageReference::Pointer dataStorageRef)=0