Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitk::WorkbenchUtil Struct Reference

Utility class for loading data, opening editors and other tasks in a MITK Workbench. More...

#include <mitkWorkbenchUtil.h>

Static Public Member Functions

static void LoadFiles (const QStringList &fileNames, berry::IWorkbenchWindow::Pointer wnd, bool openEditor=true)
 
static berry::IEditorPart::Pointer OpenEditor (berry::IWorkbenchPage::Pointer page, berry::IEditorInput::Pointer input, const QString &editorId, bool activate=false)
 
static berry::IEditorPart::Pointer OpenEditor (berry::IWorkbenchPage::Pointer page, mitk::DataStorageEditorInput::Pointer input, bool activate=false, bool determineContentType=false)
 
static berry::IEditorDescriptor::Pointer GetEditorDescriptor (const QString &name, bool inferContentType=true)
 
static berry::IEditorDescriptor::Pointer GetDefaultEditor (const QString &file, bool determineContentType)
 
static bool SetDepartmentLogoPreference (const QString &logoResource, ctkPluginContext *context)
 

Detailed Description

Utility class for loading data, opening editors and other tasks in a MITK Workbench.

Note
Infering the content type is not yet supported (ignore the comments about it in the method documentation).

Definition at line 40 of file mitkWorkbenchUtil.h.

Member Function Documentation

berry::IEditorDescriptor::Pointer mitk::WorkbenchUtil::GetDefaultEditor ( const QString &  file,
bool  determineContentType 
)
static

Returns the default editor for a given file. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings if determineContentType is true.

A default editor id may be registered for a specific file using setDefaultEditor. If the given file has a registered default editor id the default editor will derived from it. If not, the default editor is determined by taking the file name for the file and obtaining the default editor for that name.

Parameters
filethe file
determineContentTypedetermine the content type for the given file
Returns
the descriptor of the default editor, or null if not found

Definition at line 251 of file mitkWorkbenchUtil.cpp.

References berry::IEditorRegistry::FindEditor(), berry::IEditorRegistry::GetDefaultEditor(), berry::IWorkbench::GetEditorRegistry(), berry::PlatformUI::GetWorkbench(), and berry::SmartPointer< TObjectType >::IsNotNull().

Referenced by OpenEditor().

berry::IEditorDescriptor::Pointer mitk::WorkbenchUtil::GetEditorDescriptor ( const QString &  name,
bool  inferContentType = true 
)
static

Returns an editor descriptor appropriate for opening a file resource with the given name.

The editor descriptor is determined using a multi-step process. This method will attempt to infer the content type of the file if inferContentType is true.

  1. The file is consulted for a persistent property named IDE.EDITOR_KEY containing the preferred editor id to be used.
  2. The workbench editor registry is consulted to determine if an editor extension has been registered for the file type. If so, an instance of the editor extension is opened on the file. See IEditorRegistry::GetDefaultEditor(std::string).
  3. The operating system is consulted to determine if an in-place component editor is available (e.g. OLE editor on Win32 platforms).
  4. The operating system is consulted to determine if an external editor is available.
Parameters
namethe file name
inferContentTypeattempt to infer the content type from the file name if this is true
Returns
an editor descriptor, appropriate for opening the file
Exceptions
PartInitExceptionif no editor can be found

Definition at line 233 of file mitkWorkbenchUtil.cpp.

References berry::IEditorRegistry::GetDefaultEditor(), berry::IWorkbench::GetEditorRegistry(), and berry::PlatformUI::GetWorkbench().

void mitk::WorkbenchUtil::LoadFiles ( const QStringList &  fileNames,
berry::IWorkbenchWindow::Pointer  wnd,
bool  openEditor = true 
)
static

Loads the set of given files into the active data storage of the given Workbench window.

If the window already has an editor open on the active datastorage then that editor is activated; otherwise the default editor for the "mitk" extension is activated.

Parameters
fileNamesA list of file names with absolute path.
wndThe Workbench window in which the data will be loaded.
openEditorWhether an Editor is to be opened on file loading (for cases there is none).
See also
mitk::IDataNodeReader

Definition at line 99 of file mitkWorkbenchUtil.cpp.

References mitk::IDataStorageService::GetDataStorage(), mitk::RenderingManager::GetInstance(), berry::SmartPointer< TObjectType >::GetPointer(), berry::Platform::GetPreferencesService(), berry::IPreferencesService::GetSystemPreferences(), mitk::RenderingManager::InitializeViewsByBoundingObjects(), berry::SmartPointer< TObjectType >::IsNotNull(), berry::SmartPointer< TObjectType >::IsNull(), QmitkIOUtil::Load(), MITK_INFO, MITK_WARN, and OpenEditor().

Referenced by QmitkDefaultDropTargetListener::DropEvent(), and QmitkFileOpenAction::Run().

berry::IEditorPart::Pointer mitk::WorkbenchUtil::OpenEditor ( berry::IWorkbenchPage::Pointer  page,
berry::IEditorInput::Pointer  input,
const QString &  editorId,
bool  activate = false 
)
static

Opens an editor on the given object.

If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened. If activate == true the editor will be activated.

Parameters
pagethe page in which the editor will be opened
inputthe editor input
editorIdthe id of the editor extension to use
activateif true the editor will be activated
Returns
an open editor or null if an external editor was opened
Exceptions
PartInitExceptionif the editor could not be initialized
See also
IWorkbenchPage::OpenEditor(IEditorInput::Pointer, std::string, bool)

Definition at line 199 of file mitkWorkbenchUtil.cpp.

References berry::SmartPointer< TObjectType >::IsNull().

Referenced by QmitkAbstractView::GetRenderWindowPart(), LoadFiles(), and QmitkExtWorkbenchWindowAdvisor::PostWindowOpen().

berry::IEditorPart::Pointer mitk::WorkbenchUtil::OpenEditor ( berry::IWorkbenchPage::Pointer  page,
mitk::DataStorageEditorInput::Pointer  input,
bool  activate = false,
bool  determineContentType = false 
)
static

Opens an editor on the given file resource. This method will attempt to resolve the editor based on content-type bindings as well as traditional name/extension bindings if determineContentType is true.

If the page already has an editor open on the target object then that editor is brought to front; otherwise, a new editor is opened. If activate == true the editor will be activated.

Parameters
pagethe page in which the editor will be opened
inputthe editor input
activateif true the editor will be activated
determineContentTypeattempt to resolve the content type for this file
Returns
an open editor or null if an external editor was opened
Exceptions
PartInitExceptionif the editor could not be initialized
See also
IWorkbenchPage::OpenEditor(IEditorInput::Pointer,std::string,bool)

Definition at line 213 of file mitkWorkbenchUtil.cpp.

References GetDefaultEditor(), berry::PlatformUI::GetWorkbench(), and berry::SmartPointer< TObjectType >::IsNull().

bool mitk::WorkbenchUtil::SetDepartmentLogoPreference ( const QString &  logoResource,
ctkPluginContext *  context 
)
static

Set the "DepartmentLogo" preference using a Qt resource path.

This is a convenience method to set the preference for a "deparment" logo which is usually shown in render windows in the MITK workbench.

Parameters
logoResourceA Qt resource path to the logo, e.g. ":/MyLogo.png".
contextThe plugin context of the plug-in containing the logo resource.
Returns
true if the preference was set successfully, false otherwise.

Definition at line 283 of file mitkWorkbenchUtil.cpp.

References BERRY_WARN, and berry::IPreferencesService::GetSystemPreferences().


The documentation for this struct was generated from the following files: