41 #include <QMessageBox>
42 #include <QApplication>
45 #include "internal/org_mitk_gui_common_Activator.h"
49 struct WorkbenchUtilPrivate {
72 return defaultDescriptor;
92 throw berry::PartInitException(
"No editor found");
102 if (fileNames.empty())
108 ctkPluginContext* context = mitk::PluginActivator::GetContext();
118 QString msg =
"IDataStorageService service not available. Unable to open files.";
120 QMessageBox::warning(QApplication::activeWindow(),
"Unable to open files", msg);
126 context->ungetService(dsRef);
134 #if defined(_MSC_VER) && !defined(NDEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
135 int lastCrtReportType = _CrtSetReportMode( _CRT_ASSERT, _CRTDBG_MODE_DEBUG );
148 const bool dsmodified = !data->empty();
151 #if defined(_MSC_VER) && !defined(NDEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
152 if (lastCrtReportType)
153 _CrtSetReportMode( _CRT_ASSERT, lastCrtReportType );
157 if (window->GetActivePage().
IsNull())
159 QString defaultPerspId = window->GetWorkbench()->GetPerspectiveRegistry()->GetDefaultPerspective();
160 window->GetWorkbench()->ShowPerspective(defaultPerspId, window);
163 bool globalReinitOnNodeAdded =
true;
165 if (prefService !=
nullptr)
171 globalReinitOnNodeAdded = prefs->GetBool(
"Call global reinit if node is added",
true);
175 if (openEditor && globalReinitOnNodeAdded)
185 if(dsmodified && renderingManager)
190 catch (
const berry::PartInitException& e)
192 QString msg =
"An error occurred when displaying the file(s): %1";
193 QMessageBox::warning(QApplication::activeWindow(),
"Error displaying file",
194 msg.arg(e.message()));
201 const QString &editorId,
bool activate)
206 throw std::invalid_argument(
"page argument must not be NULL");
210 return page->OpenEditor(input, editorId, activate);
216 bool determineContentType)
221 throw std::invalid_argument(
"page argument must not be NULL");
225 QString name = input->GetName() +
".mitk";
227 WorkbenchUtilPrivate::GetEditorDescriptor(name,
230 return page->OpenEditor(input, editorDesc->GetId(), activate);
234 const QString& name,
bool )
238 throw std::invalid_argument(
"name argument must not be empty");
247 return WorkbenchUtilPrivate::GetEditorDescriptor(name, editorReg,
259 if (!editorID.isEmpty())
285 if (context ==
nullptr)
287 BERRY_WARN <<
"Plugin context invalid, unable to set custom logo.";
294 const QString logoFileName = logoResource.mid(logoResource.lastIndexOf(
'/')+1);
296 if (logoFileName.isEmpty())
298 BERRY_WARN <<
"Logo file name empty, unable to set custom logo.";
302 const QString logoPath = context->getDataFile(
"").absoluteFilePath();
304 bool extractLogo =
true;
305 QFileInfo logoFileInfo(logoPath +
"/" + logoFileName);
307 if (logoFileInfo.exists())
311 QString pluginLocation = QUrl(context->getPlugin()->getLocation()).toLocalFile();
312 if (!pluginLocation.isEmpty())
314 QFileInfo pluginFileInfo(pluginLocation);
315 if (logoFileInfo.lastModified() > pluginFileInfo.lastModified())
325 QFile logo(logoResource);
329 BERRY_WARN <<
"Custom logo '" << logoResource <<
"' does not exist.";
333 if (logo.open(QIODevice::ReadOnly))
335 QFile localLogo(logoPath +
"/" + logoFileName);
337 if (localLogo.open(QIODevice::WriteOnly))
339 localLogo.write(logo.readAll());
345 logoFileInfo.refresh();
347 if (logoFileInfo.exists())
359 prefService->
GetSystemPreferences()->Put(
"DepartmentLogo", qPrintable(logoFileInfo.absoluteFilePath()));
363 BERRY_WARN <<
"Preferences service not available, unable to set custom logo.";
369 BERRY_WARN <<
"Custom logo at '" << logoFileInfo.absoluteFilePath().toStdString() <<
"' does not exist.";
static const QString SYSTEM_INPLACE_EDITOR_ID
static berry::IEditorDescriptor::Pointer GetDefaultEditor(const QString &file, bool determineContentType)
itk::SmartPointer< Self > Pointer
virtual IEditorDescriptor::Pointer FindEditor(const QString &editorId)=0
static berry::IEditorDescriptor::Pointer GetEditorDescriptor(const QString &name, bool inferContentType=true)
virtual IDataStorageReference::Pointer GetDataStorage() const =0
Interface for a MITK Workbench Part providing a render window.
DataCollection - Class to facilitate loading/accessing structured data.
virtual SmartPointer< IPreferences > GetSystemPreferences()=0
static bool SetDepartmentLogoPreference(const QString &logoResource, ctkPluginContext *context)
static void LoadFiles(const QStringList &fileNames, berry::IWorkbenchWindow::Pointer wnd, bool openEditor=true)
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
static RenderingManager * GetInstance()
virtual IEditorDescriptor::Pointer GetDefaultEditor()=0
static QList< mitk::BaseData::Pointer > Load(const QStringList &paths, QWidget *parent=NULL)
Loads the specified files.
ObjectType * GetPointer() const
virtual bool IsSystemInPlaceEditorAvailable(const QString &filename)=0
virtual bool IsSystemExternalEditorAvailable(const QString &filename)=0
static berry::IEditorPart::Pointer OpenEditor(berry::IWorkbenchPage::Pointer page, berry::IEditorInput::Pointer input, const QString &editorId, bool activate=false)
static const QString SYSTEM_EXTERNAL_EDITOR_ID
virtual void InitializeViewsByBoundingObjects(const DataStorage *)
Initializes the renderwindows by the aggregated geometry of all objects that are held in the data sto...
An interface for accessing a mitk::RenderingManager instance.
virtual IEditorRegistry * GetEditorRegistry() const =0