Medical Imaging Interaction Toolkit  2023.12.00
Medical Imaging Interaction Toolkit
berry::Saveable Class Referenceabstract

#include <berrySaveable.h>

Inheritance diagram for berry::Saveable:
Collaboration diagram for berry::Saveable:

Public Types

typedef QSet< Saveable::PointerSet
 
- Public Types inherited from berry::Object
typedef Object Self
 
typedef berry::SmartPointer< SelfPointer
 
typedef berry::SmartPointer< const SelfConstPointer
 
typedef berry::WeakPointer< SelfWeakPtr
 
typedef berry::WeakPointer< const SelfConstWeakPtr
 

Public Member Functions

 berryObjectMacro (Saveable)
 
virtual bool Show (SmartPointer< IWorkbenchPage > page)
 
virtual QString GetName () const =0
 
virtual QString GetToolTipText () const =0
 
virtual QIcon GetImageDescriptor () const =0
 
virtual void DoSave ()=0
 
virtual bool IsDirty () const =0
 
bool operator< (const Object *object) const override=0
 
uint HashCode () const override=0
 
virtual void DisableUI (const QList< SmartPointer< IWorkbenchPart > > &parts, bool closing)
 
virtual void EnableUI (QList< SmartPointer< IWorkbenchPart > > &parts)
 
- Public Member Functions inherited from berry::Object
virtual QString GetClassName () const
 
virtual Reflection::TypeInfo GetTypeInfo () const
 
virtual QList< Reflection::TypeInfoGetSuperclasses () const
 
virtual void Delete ()
 
QDebug Print (QDebug os, Indent Indent=0) const
 
virtual QString ToString () const
 
void Register () const
 
void UnRegister (bool del=true) const
 
int GetReferenceCount () const
 
void SetReferenceCount (int)
 
void AddDestroyListener (const MessageAbstractDelegate<> &delegate) const
 
void RemoveDestroyListener (const MessageAbstractDelegate<> &delegate) const
 
virtual bool operator== (const Object *) const
 
- Public Member Functions inherited from berry::IAdaptable
template<class A >
A * GetAdapter ()
 
virtual ~IAdaptable ()
 

Protected Member Functions

ObjectGetAdapter (const QString &adapter) const override
 
- Protected Member Functions inherited from berry::Object
 Object ()
 
virtual ~Object ()
 
virtual QDebug PrintSelf (QDebug os, Indent indent) const
 
virtual QDebug PrintHeader (QDebug os, Indent indent) const
 
virtual QDebug PrintTrailer (QDebug os, Indent indent) const
 

Additional Inherited Members

- Static Public Member Functions inherited from berry::Object
static const char * GetStaticClassName ()
 
static Reflection::TypeInfo GetStaticTypeInfo ()
 
static QList< Reflection::TypeInfoGetStaticSuperclasses ()
 
- Protected Attributes inherited from berry::Object
QAtomicInt m_ReferenceCount
 
QMutex m_ReferenceCountLock
 

Detailed Description

A Saveable represents a unit of saveability, e.g. an editable subset of the underlying domain model that may contain unsaved changes. Different workbench parts (editors and views) may present the same saveables in different ways. This interface allows the workbench to provide more appropriate handling of operations such as saving and closing workbench parts. For example, if two editors sharing the same saveable with unsaved changes are closed simultaneously, the user is only prompted to save the changes once for the shared saveable, rather than once for each editor.

Workbench parts that work in terms of saveables should implement ISaveablesSource.

See also
ISaveablesSource

Definition at line 44 of file berrySaveable.h.

Member Typedef Documentation

◆ Set

Definition at line 51 of file berrySaveable.h.

Member Function Documentation

◆ berryObjectMacro()

berry::Saveable::berryObjectMacro ( Saveable  )

◆ DisableUI()

virtual void berry::Saveable::DisableUI ( const QList< SmartPointer< IWorkbenchPart > > &  parts,
bool  closing 
)
virtual

Disables the UI of the given parts containing this saveable if necessary. This method is not intended to be called by clients. A corresponding call to

Saveables that can be saved in the background should ensure that the user cannot make changes to their data from the UI, for example by disabling controls, unless they are prepared to handle this case. This method is called on the UI thread after a job runnable has been returned from doSave(IProgressMonitor, IShellProvider) and before spinning the event loop. The closing flag indicates that this saveable is currently being saved in response to closing a workbench part, in which case further changes to this saveable through the UI must be prevented.

The default implementation calls setEnabled(false) on the given parts' composites.

Parameters
partsthe workbench parts containing this saveable
closinga boolean flag indicating whether the save was triggered by a request to close a workbench part, and all of the given parts will be closed after the save operation finishes successfully.
Since
3.3

◆ DoSave()

virtual void berry::Saveable::DoSave ( )
pure virtual

Saves the contents of this saveable.

If the save is cancelled through user action, or for any other reason, the part should invoke setCancelled on the IProgressMonitor to inform the caller.

This method is long-running; progress and cancellation are provided by the given progress monitor.

Exceptions
CoreExceptionif the save fails; it is the caller's responsibility to report the failure to the user

◆ EnableUI()

virtual void berry::Saveable::EnableUI ( QList< SmartPointer< IWorkbenchPart > > &  parts)
virtual

Enables the UI of the given parts containing this saveable after a background save operation has finished. This method is not intended to be called by clients.

The default implementation calls setEnabled(true) on the given parts' composites.

Parameters
partsthe workbench parts containing this saveable
Since
3.3

◆ GetAdapter()

Object* berry::Saveable::GetAdapter ( const QString &  adapter) const
overrideprotectedvirtual

This implementation of IAdaptable.GetAdapterImpl(const std::type_info&) returns null. Subclasses may override. This allows two unrelated subclasses of Saveable to implement equals(Object) and hashCode() based on an underlying implementation class that is shared by both Saveable subclasses.

Since
3.3

Implements berry::IAdaptable.

◆ GetImageDescriptor()

virtual QIcon berry::Saveable::GetImageDescriptor ( ) const
pure virtual

Returns the image descriptor for this saveable.

Returns
the image descriptor for this model; may be null if there is no image

◆ GetName()

virtual QString berry::Saveable::GetName ( ) const
pure virtual

Returns the name of this saveable for display purposes.

Returns
the model's name; never null.

◆ GetToolTipText()

virtual QString berry::Saveable::GetToolTipText ( ) const
pure virtual

Returns the tool tip text for this saveable. This text is used to differentiate between two inputs with the same name. For instance, MyClass.java in folder X and MyClass.java in folder Y. The format of the text varies between input types.

Returns
the tool tip text; never null

◆ HashCode()

uint berry::Saveable::HashCode ( ) const
overridepure virtual

Clients must implement equals and hashCode as defined in Object.equals(Object) and Object.hashCode() . Two saveables should be equal if their dirty state is shared, and saving one will save the other. If two saveables are equal, their hash codes MUST be the same, and their names, tooltips, and images should be the same because only one of them will be shown when prompting the user to save.

IMPORTANT: Implementers should ensure that the hashCode returned is sufficiently unique so as not to collide with hashCodes returned by other implementations. It is suggested that the defining plug-in's ID be used as part of the returned hashCode, as in the following example:

    int PRIME = 31;
    int hash = ...; // compute the "normal" hash code, e.g. based on some identifier unique within the defining plug-in
    return hash * PRIME + MY_PLUGIN_ID.hashCode();
Returns
a hash code

Reimplemented from berry::Object.

◆ IsDirty()

virtual bool berry::Saveable::IsDirty ( ) const
pure virtual

Returns whether the contents of this saveable have changed since the last save operation.

Note: this method is called frequently, for example by actions to determine their enabled status.

Returns
true if the contents have been modified and need saving, and false if they have not changed since the last save

◆ operator<()

bool berry::Saveable::operator< ( const Object object) const
overridepure virtual

Clients must implement equals and hashCode as defined in Object.equals(Object) and Object.hashCode() . Two saveables should be equal if their dirty state is shared, and saving one will save the other. If two saveables are equal, their names, tooltips, and images should be the same because only one of them will be shown when prompting the user to save.

Parameters
object
Returns
true if this Saveable is equal to the given object

Reimplemented from berry::Object.

◆ Show()

virtual bool berry::Saveable::Show ( SmartPointer< IWorkbenchPage page)
virtual

Attempts to show this saveable in the given page and returns true on success. The default implementation does nothing and returns false.

Parameters
pagethe workbench page in which to show this saveable
Returns
true if this saveable is now visible to the user
Since
3.3

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