Medical Imaging Interaction Toolkit  2024.06.99-caca2dd0
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>

Public Types

enum  IRenderWindowPartStrategy { NONE, BRING_TO_FRONT, ACTIVATE, OPEN }
 

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, 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 IRenderWindowPartGetRenderWindowPart (berry::IWorkbenchPage::Pointer page, IRenderWindowPartStrategies strategies)
 Returns the currently active mitk::IRenderWindowPart. More...
 
static IRenderWindowPartOpenRenderWindowPart (berry::IWorkbenchPage::Pointer page, bool activatedEditor=true)
 Uses 'GetRenderWindowPart' to open the a render window part with a certain strategy: Calls 'GetRenderWindowPart' with strategy "ACTIVATE | OPEN" if the bool argument is true. Calls 'GetRenderWindowPart' with strategy "BRING_TO_FRONT | OPEN" if the bool argument is false. More...
 
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
Inferring the content type is not yet supported (ignore the comments about it in the method documentation).

Definition at line 37 of file mitkWorkbenchUtil.h.

Member Enumeration Documentation

◆ IRenderWindowPartStrategy

Describes the strategies to be used for getting an mitk::IRenderWindowPart instance.

Enumerator
NONE 
BRING_TO_FRONT 
ACTIVATE 
OPEN 

Definition at line 42 of file mitkWorkbenchUtil.h.

Member Function Documentation

◆ GetDefaultEditor()

static 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

◆ GetEditorDescriptor()

static 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

◆ GetRenderWindowPart()

static IRenderWindowPart* mitk::WorkbenchUtil::GetRenderWindowPart ( berry::IWorkbenchPage::Pointer  page,
IRenderWindowPartStrategies  strategies 
)
static

Returns the currently active mitk::IRenderWindowPart.

Parameters
pageThe page in which the editor will be opened.
strategiesStrategies for returning a mitk::IRenderWindowPart instance if there is currently no active one.
Returns
The active mitk::IRenderWindowPart.

◆ LoadFiles()

static 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::IOUtil

◆ OpenEditor() [1/2]

static 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)

◆ OpenEditor() [2/2]

static berry::IEditorPart::Pointer mitk::WorkbenchUtil::OpenEditor ( berry::IWorkbenchPage::Pointer  page,
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)

◆ OpenRenderWindowPart()

static IRenderWindowPart* mitk::WorkbenchUtil::OpenRenderWindowPart ( berry::IWorkbenchPage::Pointer  page,
bool  activatedEditor = true 
)
static

Uses 'GetRenderWindowPart' to open the a render window part with a certain strategy: Calls 'GetRenderWindowPart' with strategy "ACTIVATE | OPEN" if the bool argument is true. Calls 'GetRenderWindowPart' with strategy "BRING_TO_FRONT | OPEN" if the bool argument is false.

Parameters
pageThe page in which the editor will be opened.
activatedEditorDetermine if the render window part should be activated or just brought to front.
Returns
The active and opened mitk::IRenderWindowPart.

◆ SetDepartmentLogoPreference()

static 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 "department" 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.

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