Medical Imaging Interaction Toolkit  2023.12.99-3b10b122
Medical Imaging Interaction Toolkit
berry::WorkbenchAdvisor Class Referenceabstract

#include <berryWorkbenchAdvisor.h>

Inheritance diagram for berry::WorkbenchAdvisor:

Public Member Functions

void InternalBasicInitialize (IWorkbenchConfigurer::Pointer configurer)
 
virtual void Initialize (IWorkbenchConfigurer::Pointer configurer)
 
virtual void PreStartup ()
 
virtual void PostStartup ()
 
virtual bool PreShutdown ()
 
virtual void PostShutdown ()
 
virtual WorkbenchWindowAdvisorCreateWorkbenchWindowAdvisor (IWorkbenchWindowConfigurer::Pointer configurer)=0
 
virtual IAdaptableGetDefaultPageInput ()
 
virtual QString GetInitialWindowPerspectiveId ()=0
 
virtual QString GetMainPreferencePageId ()
 
virtual bool OpenWindows ()
 
virtual bool SaveState (IMemento::Pointer memento)
 
virtual bool RestoreState (IMemento::Pointer memento)
 

Protected Member Functions

 WorkbenchAdvisor ()
 
virtual ~WorkbenchAdvisor ()
 
IWorkbenchConfigurer::Pointer GetWorkbenchConfigurer ()
 

Detailed Description

public: base class for configuring the workbench.

Note that the workbench advisor object is created in advance of creating the workbench. However, by the time the workbench starts calling methods on this class, PlatformUI::GetWorkbench() is guaranteed to have been properly initialized.

Example of creating and running a workbench (in an berry::IApplication):


          class MyApplication : public berry::IApplication {
            public:
            int Start()
            {
              WorkbenchAdvisor* workbenchAdvisor = new MyWorkbenchAdvisor();
              berry::Display* display = berry::PlatformUI::CreateDisplay();
              int returnCode = berry::PlatformUI::CreateAndRunWorkbench(display, workbenchAdvisor);
              if (returnCode == PlatformUI::RETURN_RESTART) {
                 return berry::IApplication::EXIT_RESTART;
              } else {
                 return berry::IApplication::EXIT_OK;
            }
          };

An application should declare a subclass of berry::WorkbenchAdvisor and override methods to configure the workbench to suit the needs of the particular application.

The following advisor methods are called at strategic points in the workbench's lifecycle (all occur within the dynamic scope of the call to PlatformUI::CreateAndRunWorkbench()):

  • Initialize() - called first; before any windows; use to register things
  • PreStartup() - called second; after initialize but before first window is opened; use to temporarily disable things during startup or restore
  • PostStartup() - called third; after first window is opened; use to reenable things temporarily disabled in previous step
  • EventLoopException() - called to handle the case where the event loop has crashed; use to inform the user that things are not well (not implemented yet)
  • EventLoopIdle() - called when there are currently no more events to be processed; use to perform other work or to yield until new events enter the queue (not implemented yet)
  • PreShutdown() - called immediately prior to workbench shutdown before any windows have been closed; allows the advisor to veto the shutdown
  • PostShutdown() - called last; after event loop has terminated and all windows have been closed; use to deregister things registered during initialize

Definition at line 92 of file berryWorkbenchAdvisor.h.

Constructor & Destructor Documentation

◆ WorkbenchAdvisor()

berry::WorkbenchAdvisor::WorkbenchAdvisor ( )
protected

Creates and initializes a new workbench advisor instance.

◆ ~WorkbenchAdvisor()

virtual berry::WorkbenchAdvisor::~WorkbenchAdvisor ( )
protectedvirtual

Member Function Documentation

◆ CreateWorkbenchWindowAdvisor()

virtual WorkbenchWindowAdvisor* berry::WorkbenchAdvisor::CreateWorkbenchWindowAdvisor ( IWorkbenchWindowConfigurer::Pointer  configurer)
pure virtual

Creates a new workbench window advisor for configuring a new workbench window via the given workbench window configurer. Clients should override to provide their own window configurer.

Parameters
configurerthe workbench window configurer
Returns
a new workbench window advisor

◆ GetDefaultPageInput()

virtual IAdaptable* berry::WorkbenchAdvisor::GetDefaultPageInput ( )
virtual

Returns the default input for newly created workbench pages when the input is not explicitly specified.

The default implementation returns null. Subclasses may override.

Returns
the default input for a new workbench window page, or null if none
See also
CreateWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer::Pointer)

◆ GetInitialWindowPerspectiveId()

virtual QString berry::WorkbenchAdvisor::GetInitialWindowPerspectiveId ( )
pure virtual

Returns the id of the perspective to use for the initial workbench window, or null if no initial perspective should be shown in the initial workbench window.

This method is called during startup when the workbench is creating the first new window. Subclasses must implement.

If the WorkbenchPreferenceConstants::DEFAULT_PERSPECTIVE_ID preference is specified, it supercedes the perspective specified here.

Returns
the id of the perspective for the initial window, or null if no initial perspective should be shown

◆ GetMainPreferencePageId()

virtual QString berry::WorkbenchAdvisor::GetMainPreferencePageId ( )
virtual

Returns the id of the preference page that should be presented most prominently.

The default implementation returns null. Subclasses may override.

Returns
the id of the preference page, or null if none

◆ GetWorkbenchConfigurer()

IWorkbenchConfigurer::Pointer berry::WorkbenchAdvisor::GetWorkbenchConfigurer ( )
protected

Returns the workbench configurer for the advisor. Can be null if the advisor is not initialized yet.

Returns
the workbench configurer, or null if the advisor is not initialized yet

◆ Initialize()

virtual void berry::WorkbenchAdvisor::Initialize ( IWorkbenchConfigurer::Pointer  configurer)
virtual

Performs arbitrary initialization before the workbench starts running.

This method is called during workbench initialization prior to any windows being opened. Clients must not call this method directly (although super calls are okay). The default implementation does nothing. Subclasses may override. Typical clients will use the configurer passed in to tweak the workbench. If further tweaking is required in the future, the configurer may be obtained using GetWorkbenchConfigurer().

Parameters
configureran object for configuring the workbench

Reimplemented in berry::QtWorkbenchAdvisor.

◆ InternalBasicInitialize()

void berry::WorkbenchAdvisor::InternalBasicInitialize ( IWorkbenchConfigurer::Pointer  configurer)

Remembers the configurer and calls Initialize().

For internal use by the workbench only.

Parameters
configureran object for configuring the workbench

◆ OpenWindows()

virtual bool berry::WorkbenchAdvisor::OpenWindows ( )
virtual

Opens the workbench windows on startup. The default implementation tries to restore the previously saved workbench state using IWorkbenchConfigurer::RestoreState(). If there was no previously saved state, or if the restore failed, then a first-time window is opened using IWorkbenchConfigurer::OpenFirstTimeWindow().

Returns
true to proceed with workbench startup, or false to exit

◆ PostShutdown()

virtual void berry::WorkbenchAdvisor::PostShutdown ( )
virtual

Performs arbitrary finalization after the workbench stops running.

This method is called during workbench shutdown after all windows have been closed. Clients must not call this method directly (although super calls are okay). The default implementation does nothing. Subclasses may override.

◆ PostStartup()

virtual void berry::WorkbenchAdvisor::PostStartup ( )
virtual

Performs arbitrary actions after the workbench windows have been opened (or restored), but before the main event loop is run.

This method is called just after the windows have been opened. Clients must not call this method directly (although super calls are okay). The default implementation does nothing. Subclasses may override. It is okay to call IWorkbench::Close() from this method.

◆ PreShutdown()

virtual bool berry::WorkbenchAdvisor::PreShutdown ( )
virtual

Performs arbitrary finalization before the workbench is about to shut down.

This method is called immediately prior to workbench shutdown before any windows have been closed. Clients must not call this method directly (although super calls are okay). The default implementation returns true. Subclasses may override.

The advisor may veto a regular shutdown by returning false, although this will be ignored if the workbench is being forced to shut down.

Returns
true to allow the workbench to proceed with shutdown, false to veto a non-forced shutdown

◆ PreStartup()

virtual void berry::WorkbenchAdvisor::PreStartup ( )
virtual

Performs arbitrary actions just before the first workbench window is opened (or restored).

This method is called after the workbench has been initialized and just before the first window is about to be opened. Clients must not call this method directly (although super calls are okay). The default implementation does nothing. Subclasses may override.

◆ RestoreState()

virtual bool berry::WorkbenchAdvisor::RestoreState ( IMemento::Pointer  memento)
virtual

Restores arbitrary application-specific state information for this workbench advisor.

The default implementation simply returns an OK status. Subclasses may extend or override.

Parameters
mementothe memento from which to restore the advisor's state
Returns
a status object indicating whether the restore was successful

◆ SaveState()

virtual bool berry::WorkbenchAdvisor::SaveState ( IMemento::Pointer  memento)
virtual

Saves arbitrary application-specific state information for this workbench advisor.

The default implementation simply returns an OK status. Subclasses may extend or override.

Parameters
mementothe memento in which to save the advisor's state
Returns
a status object indicating whether the save was successful

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