OOFILE  1.9
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dbEditHelper Class Reference

dbHelper that manages edit controls accessing a main record. More...

#include <oofpp.h>

Inheritance diagram for dbEditHelper:
Inheritance graph
[legend]
Collaboration diagram for dbEditHelper:
Collaboration graph
[legend]

Public Member Functions

void addReceiver (oofReceiver *)
 Append receiver to end of list. More...
 
void adoptLink (dbFieldLink *adoptedLink)
 
bool askAllReturningAny (bool returnAny, OOFmsgT msg, unsigned long senderDefined=0, const oofReceiver *skipping=0)
 
oofReceiveraskAllStoppingAtFirst (bool stopOn, OOFmsgT msg, unsigned long senderDefined=0, const oofReceiver *skipping=0)
 
void broadcast (OOFmsgT msg, unsigned long senderDefined=0, const oofReceiver *skipping=0)
 Broadcast a message to all anonymous subscribers. More...
 
void copyFieldsToLinks ()
 
void copyLinksToFields ()
 
virtual void * currentGUItarget () const
 
 dbEditHelper (dbTable *)
 
dbFieldLinkgetLink (void *)
 
bool isBroadcasting () const
 
bool isDirty ()
 Check if helper is dirty, implied by mMainTable being dirty. More...
 
bool isReadOnly () const
 
void linkAdapter (dbField &, dbGUIAdapter *adoptedAdapter, bool becomeReadOnly=false)
 
void linkAdapter (dbField *, dbGUIAdapter *adoptedAdapter, bool becomeReadOnly=false)
 
void linkPickAdapter (dbField &, dbGUIAdapter *adoptedAdapter, bool becomeReadOnly=false, dbRelRef *pickVia=0)
 
void linkPickAdapter (dbField *, dbGUIAdapter *adoptedAdapter, bool becomeReadOnly=false, dbRelRef *pickVia=0)
 Link an Adapter to control used to select from lookup table. More...
 
virtual void maybeChangeTargetLink (dbFieldLink *)
 React to possibly leaving a field, calling validation and update methods. More...
 
virtual void maybeDirty (dbFieldLink *)
 
void msgChangedCurrentField (OOFmsgT)
 
OOFmsgT msgChangedCurrentField ()
 
void readOnly (bool isReadOnly=true)
 
virtual bool receiveMsg (OOFmsgT msg, unsigned long senderDefined)
 The default receiveMsg behaviour is to delete yourself when the broadcaster closes. More...
 
void removeReceiver (const oofReceiver *)
 
void resumeListening ()
 
virtual void subscribeTo (oofBroadcaster *)
 
void suspendListening ()
 
virtual dbTabletable () const
 
virtual void unsubscribe (oofBroadcaster *from=0)
 
virtual void updateDerivedFieldDisplays ()
 
platform-specific links
void linkField (dbField &, const dbGUIAdapterFactoryPP &)
 
void linkField (dbField *, const dbGUIAdapterFactoryPP &)
 
void linkPickField (dbField &, const dbGUIAdapterFactoryPP &, dbRelRef *pickVia=0)
 
void linkPickField (dbField *, const dbGUIAdapterFactoryPP &, dbRelRef *pickVia=0)
 
USER-HOOK messages as alternative to subclassing and overriding the hook methods
void msgEnteringAboutToLoad (OOFmsgT)
 
OOFmsgT msgEnteringAboutToLoad ()
 
void msgEnteringAfterLoad (OOFmsgT)
 
OOFmsgT msgEnteringAfterLoad ()
 
void msgCanSaveRecord (OOFmsgT)
 
OOFmsgT msgCanSaveRecord ()
 
void msgConfirmSave (OOFmsgT)
 
OOFmsgT msgConfirmSave ()
 

Static Public Member Functions

static void warnUser (std::ostream &os)
 

Protected Member Functions

void BroadcastShutdown ()
 
virtual bool LeaveRecord ()
 Leave record, asking user to OK changes if necessary. More...
 
virtual void LoadData ()
 
void ResetDirtyLinks ()
 
virtual bool SendFrameworkMessage (OOFmsgT, void *ioParam=0)
 
virtual bool SendImmediateFrameworkMessage (OOFmsgT, void *ioParam=0)
 Send a message so any listeners can approve an action. More...
 
bool ValidateLinks ()
 Check all links to see if they are validToLeaveForm, stopping at first failure. More...
 
USER-HOOKS override the following virtual methods as documented in guihooks.htm
virtual void EnteringAboutToLoad ()
 
virtual void EnteringAfterLoad ()
 
virtual bool CanSaveRecord ()
 
virtual YNCancelT ConfirmSave ()
 Ask user to confirm if should save or not, allowing cancel. More...
 
virtual void ChangedCurrentField ()
 

Protected Attributes

bool mAutoSaveOnMoving
 
bool mChangingPages
 
dbFieldLinkmCurrentLink
 
OOF_Dictionary mLinks
 
oofBroadcastermListensTo
 
bool mLostReceiversWhileBroadcasting
 simple flag that removeReceiver was called during nested broadcast More...
 
dbTablemMainTable
 
OOFmsgT mMsgCanSaveRecord
 
OOFmsgT mMsgChangedCurrentField
 
OOFmsgT mMsgConfirmSave
 
OOFmsgT mMsgEnteringAboutToLoad
 
OOFmsgT mMsgEnteringAfterLoad
 
unsigned long mNestedBroadcastingDepth
 aid to debugging and removeReceiver More...
 
bool mReadOnly
 
OOF_ExpandableLongArraymReceivers
 owned More...
 
unsigned short mSuspendCount
 
oofBroadcastermSuspendedListensTo
 

Detailed Description

dbHelper that manages edit controls accessing a main record.

May have related data to the main table being edited. There will be one of these per dialog editing a record except possibly if the only controls on the dialog are lists of records. This copy of the class implements PowerPlant linkField methods. dbEditHelper will be reimplemented for each GUI platform and has linkField classes for that GUI's different control types.

Definition at line 450 of file oofpp.h.

Constructor & Destructor Documentation

dbEditHelper::dbEditHelper ( dbTable tbl)

Definition at line 666 of file oofpp.cpp.

Member Function Documentation

void oofBroadcaster::addReceiver ( oofReceiver addingReceiver)
inherited

Append receiver to end of list.

Includes assertion to check if already in list.

Definition at line 181 of file oofmsg.cpp.

References OOF_ExpandableLongArray::append(), OOF_ExpandableLongArray::find(), and oofBroadcaster::mReceivers.

Referenced by oofSingleListener::oofSingleListener(), oofReceiver::subscribeTo(), and oofSingleListener::subscribeTo().

void dbAbstractEditHelper::adoptLink ( dbFieldLink adoptedLink)
inherited
bool oofBroadcaster::askAllReturningAny ( bool  returnAny,
OOFmsgT  msg,
unsigned long  senderDefined = 0,
const oofReceiver skipping = 0 
)
inherited
oofReceiver * oofBroadcaster::askAllStoppingAtFirst ( bool  stopOn,
OOFmsgT  msg,
unsigned long  senderDefined = 0,
const oofReceiver skipping = 0 
)
inherited
void oofBroadcaster::broadcast ( OOFmsgT  msg,
unsigned long  senderDefined = 0,
const oofReceiver skipping = 0 
)
inherited

Broadcast a message to all anonymous subscribers.

Parameters
msgconstant value indicating the action or event that has occurred.
senderDefinedadditional param for caller to pass through
skippinga receiver to be skipped when broadcasting, to avoid circular messages
Todo:
use void* for senderDefined so can cope with values >32bits eg oidT in HUGE databases or 64bit pointers.

Definition at line 82 of file oofmsg.cpp.

References OOF_ExpandableLongArray::count(), OOF_ExpandableLongArray::deleteAllMatching(), oofBroadcaster::mLostReceiversWhileBroadcasting, oofBroadcaster::mNestedBroadcastingDepth, oofBroadcaster::mReceivers, oofReceiver::receiveMsg(), and OOF_ExpandableLongArray::value().

Referenced by dbTable::addOIDtoSelection(), dbTable::appendSelection(), oofBroadcaster::BroadcastShutdown(), dbTable::clearSelection(), oofGraphSettingsCompleter::completePromises(), oofRepTextStyleCompleter::completePromises(), dbTable::deleteRecord(), dbTable::difference_with(), dbTable::dropRecordFromSelection(), dbTable::insert(), dbTable::intersection_with(), dbTable::invert(), dbGUI::leaveRecord(), dbAbstractEditHelper::LoadData(), dbTable::loadRelatedContextJoiningFromTo(), dbGUI::newRecord(), dbRelRefBase::relateFromRecord(), dbRelRefBase::relateRecord(), dbTable::removeSelection(), dbTable::resumeSorting(), dbGUI::revertRecord(), dbTable::revertRecord(), dbGUI::saveRecord(), dbTable::saveRecord(), dbTable::search(), dbTable::searchSelection(), dbRelRefBase::selectAllRelated(), dbTable::selectJustOID(), dbTable::setSelection(), dbTable::suspendSorting(), dbTable::union_with(), dbTable::union_with_no_overlap(), and dbTable::unloadRecord().

void oofBroadcaster::BroadcastShutdown ( )
protectedinherited
bool dbAbstractEditHelper::CanSaveRecord ( )
protectedvirtualinherited
void dbAbstractEditHelper::ChangedCurrentField ( )
protectedvirtualinherited
YNCancelT dbAbstractEditHelper::ConfirmSave ( )
protectedvirtualinherited

Ask user to confirm if should save or not, allowing cancel.

Can override by subclassing. msgConfirmSave(OOFmsgT) also lets you specify a message to be sent to application to allow confirmation - an easier way to hook in behaviour without subclassing.

Note
you could totally disable this behaviour by having your reaction to mMsgConfirmSave be No, eg: if you were running in demo mode.
Returns
triple value YNCancelT indicating user response.

Definition at line 477 of file oofgui.cpp.

References Cancel, IDCANCEL, IDNO, IDYES, dbAbstractEditHelper::mMsgConfirmSave, oofYNC::msgBox(), No, OOFmsg_None, dbAbstractEditHelper::SendImmediateFrameworkMessage(), and Yes.

Referenced by dbAbstractEditHelper::LeaveRecord().

void dbAbstractEditHelper::copyFieldsToLinks ( )
inherited
void dbAbstractEditHelper::copyLinksToFields ( )
inherited
Note
not used by OOFILE any more but User may invoke for mass update
See also
dbFieldLink::leaveLink - we copy back on field by field basis so database matches visuals, and calc fields work on the visible values

Definition at line 703 of file oofgui.cpp.

References dbFieldLink::copyLinkToField(), OOF_Dictionary::count(), and dbAbstractEditHelper::mLinks.

void * dbEditHelper::currentGUItarget ( ) const
virtual

Implements dbAbstractEditHelper.

Definition at line 673 of file oofpp.cpp.

void dbAbstractEditHelper::EnteringAboutToLoad ( )
protectedvirtualinherited
void dbAbstractEditHelper::EnteringAfterLoad ( )
protectedvirtualinherited
dbFieldLink * dbAbstractEditHelper::getLink ( void *  targetPane)
inherited
bool oofBroadcaster::isBroadcasting ( ) const
inlineinherited

Definition at line 160 of file oofmsg.h.

References oofBroadcaster::mNestedBroadcastingDepth.

bool dbAbstractEditHelper::isDirty ( )
inherited

Check if helper is dirty, implied by mMainTable being dirty.

dbField dirty back-propagation ensures edits to related data dirty main table.

Returns
true indicates dirty, will need to save

Definition at line 763 of file oofgui.cpp.

References dbTable::isDirty(), and dbAbstractEditHelper::mMainTable.

Referenced by dbAbstractEditHelper::LeaveRecord().

bool dbAbstractEditHelper::isReadOnly ( ) const
inlineinherited

Definition at line 615 of file oofgui.h.

References dbAbstractEditHelper::mReadOnly.

bool dbAbstractEditHelper::LeaveRecord ( )
protectedvirtualinherited

Leave record, asking user to OK changes if necessary.

If record needs saving and not in auto-save mode, calls ConfirmSave.

Returns
true if were allowed to leave.

Definition at line 615 of file oofgui.cpp.

References dbTable::autoOnContextChange, Cancel, dbAbstractEditHelper::CanSaveRecord(), dbAbstractEditHelper::ConfirmSave(), dbAbstractEditHelper::isDirty(), dbFieldLink::leaveLink(), dbAbstractEditHelper::mAutoSaveOnMoving, dbAbstractEditHelper::mCurrentLink, dbAbstractEditHelper::mMainTable, No, dbTable::tableSaveOption(), and dbTable::unloadRecord().

Referenced by dbAbstractEditHelper::receiveMsg().

void dbAbstractEditHelper::linkAdapter ( dbField fld,
dbGUIAdapter adoptedAdapter,
bool  becomeReadOnly = false 
)
inlineinherited

Definition at line 692 of file oofgui.h.

Referenced by linkField().

void dbAbstractEditHelper::linkAdapter ( dbField fld,
dbGUIAdapter adoptedAdapter,
bool  becomeReadOnly = false 
)
inherited
void dbEditHelper::linkField ( dbField fld,
const dbGUIAdapterFactoryPP inFactory 
)
inline
void dbEditHelper::linkField ( dbField fld,
const dbGUIAdapterFactoryPP inFactory 
)
inline
void dbAbstractEditHelper::linkPickAdapter ( dbField fld,
dbGUIAdapter adoptedAdapter,
bool  becomeReadOnly = false,
dbRelRef pickVia = 0 
)
inlineinherited

Definition at line 699 of file oofgui.h.

Referenced by linkPickField().

void dbAbstractEditHelper::linkPickAdapter ( dbField fld,
dbGUIAdapter adoptedAdapter,
bool  becomeReadOnly = false,
dbRelRef pickVia = 0 
)
inherited

Link an Adapter to control used to select from lookup table.

Often popup menu but may be an edit control - we abstract that.

Parameters
pickViaused to clarify which is lookup table, in complex multi-rel chain eg: Patients->Visits->Doctor->Staff->Name with pickVia == Patients->Visits->Doctor pickVia is the relationship going from left to right. It will usually point to the table containing the choice field, ie: fld->table()==pickVia->relatedTable().
Note
a very important role of this method is in most cases work out the default pickVia
Warning
an easy mistake is to specify just the relationship, NOT the field pointed to, eg:
mEditHelper->linkPickField (mOOFData->Prefs->DefaultAssignee, mAssignedToPopup);
instead of
mEditHelper->linkPickField (mOOFData->Prefs->DefaultAssignee->ShortDesc, mAssignedToPopup);
Todo:
allow for picking via date entry fields, like dbDateLink2Editor

Definition at line 829 of file oofgui.cpp.

References dbAbstractEditHelper::adoptLink(), dbTable::baseTableOfRelationChain(), dbField::fieldIsStandalone(), dbField::fieldTable(), dbRelRefBase::inverse(), dbRelRefBase::isManyToOne(), dbRelRefBase::isOneToOne(), and dbRelRefBase::isRelBackToParent().

void dbEditHelper::linkPickField ( dbField fld,
const dbGUIAdapterFactoryPP inFactory,
dbRelRef pickVia = 0 
)
inline
void dbEditHelper::linkPickField ( dbField fld,
const dbGUIAdapterFactoryPP inFactory,
dbRelRef pickVia = 0 
)
inline
void dbAbstractEditHelper::LoadData ( )
protectedvirtualinherited
void dbAbstractEditHelper::maybeChangeTargetLink ( dbFieldLink newLink)
virtualinherited

React to possibly leaving a field, calling validation and update methods.

Calls updateDerivedFieldDisplays so calculated fields can react to changes.

Note
some GUI toolkits rely on direct dependencies to provide this kind of updating, which has huge performance implications with cascading broadcasts (like Swing). By centralising the update here we have the chance to control GUI behaviour and react optimally.
Todo:
make field display updates optional

Reimplemented from dbHelper.

Definition at line 548 of file oofgui.cpp.

References dbAbstractEditHelper::ChangedCurrentField(), dbAbstractEditHelper::currentGUItarget(), dbAbstractEditHelper::getLink(), dbFieldLink::leaveLink(), dbAbstractEditHelper::mCurrentLink, and dbAbstractEditHelper::updateDerivedFieldDisplays().

void dbAbstractEditHelper::maybeDirty ( dbFieldLink inLink)
virtualinherited

Reimplemented from dbHelper.

Definition at line 572 of file oofgui.cpp.

References dbAbstractEditHelper::mCurrentLink.

void dbAbstractEditHelper::msgCanSaveRecord ( OOFmsgT  inMsg)
inlineinherited

Definition at line 650 of file oofgui.h.

References dbAbstractEditHelper::mMsgCanSaveRecord.

OOFmsgT dbAbstractEditHelper::msgCanSaveRecord ( )
inlineinherited

Definition at line 657 of file oofgui.h.

References dbAbstractEditHelper::mMsgCanSaveRecord.

void dbAbstractEditHelper::msgChangedCurrentField ( OOFmsgT  inMsg)
inlineinherited

Definition at line 678 of file oofgui.h.

References dbAbstractEditHelper::mMsgChangedCurrentField.

OOFmsgT dbAbstractEditHelper::msgChangedCurrentField ( )
inlineinherited

Definition at line 685 of file oofgui.h.

References dbAbstractEditHelper::mMsgChangedCurrentField.

void dbAbstractEditHelper::msgConfirmSave ( OOFmsgT  inMsg)
inlineinherited

Definition at line 664 of file oofgui.h.

References dbAbstractEditHelper::mMsgConfirmSave.

OOFmsgT dbAbstractEditHelper::msgConfirmSave ( )
inlineinherited

Definition at line 671 of file oofgui.h.

References dbAbstractEditHelper::mMsgConfirmSave.

void dbAbstractEditHelper::msgEnteringAboutToLoad ( OOFmsgT  inMsg)
inlineinherited

Definition at line 622 of file oofgui.h.

References dbAbstractEditHelper::mMsgEnteringAboutToLoad.

OOFmsgT dbAbstractEditHelper::msgEnteringAboutToLoad ( )
inlineinherited

Definition at line 629 of file oofgui.h.

References dbAbstractEditHelper::mMsgEnteringAboutToLoad.

void dbAbstractEditHelper::msgEnteringAfterLoad ( OOFmsgT  inMsg)
inlineinherited

Definition at line 636 of file oofgui.h.

References dbAbstractEditHelper::mMsgEnteringAfterLoad.

OOFmsgT dbAbstractEditHelper::msgEnteringAfterLoad ( )
inlineinherited

Definition at line 643 of file oofgui.h.

References dbAbstractEditHelper::mMsgEnteringAfterLoad.

void dbAbstractEditHelper::readOnly ( bool  isReadOnly = true)
inherited
bool dbAbstractEditHelper::receiveMsg ( OOFmsgT  msg,
unsigned long  senderDefined 
)
virtualinherited

The default receiveMsg behaviour is to delete yourself when the broadcaster closes.

In many user subclasses oofSingleListener is a mixin and you have a class owned elsewhere, not self-deleting.

\warning If a subclass is not self-deleting it MUST override receiveMsg 
handling of the msg OOFmsg_BroadcasterClosing to prevent runtime error.

However it is still important to set mListensTo=0 otherwise when you finally get around to deleting your oofSingleListener, it will try to update a deleted oofBroadcaster and cause a crash.

Reimplemented from oofSingleListener.

Definition at line 425 of file oofgui.cpp.

References dbAbstractEditHelper::CanSaveRecord(), kRecordLockedByOtherUser, dbFieldLink::leaveLink(), dbAbstractEditHelper::LeaveRecord(), dbAbstractEditHelper::LoadData(), dbAbstractEditHelper::mCurrentLink, dbAbstractEditHelper::mMainTable, OOFmsg_AttemptLeaveRecord, OOFmsg_AttemptSaveRecord, OOFmsg_ChangeSelection, OOFmsg_NewRecord, OOFmsg_RevertRecord, OOFmsg_SaveRecord, dbAbstractEditHelper::readOnly(), dbTable::reloadRecord(), dbAbstractEditHelper::ResetDirtyLinks(), and dbTable::unloadRecord().

void oofBroadcaster::removeReceiver ( const oofReceiver rcvrPtr)
inherited
void dbAbstractEditHelper::ResetDirtyLinks ( )
protectedinherited
void oofSingleListener::resumeListening ( )
inherited
bool dbEditHelper::SendFrameworkMessage ( OOFmsgT  inMsg,
void *  ioParam = 0 
)
protectedvirtual

Implements dbAbstractEditHelper.

Definition at line 690 of file oofpp.cpp.

bool dbAbstractEditHelper::SendImmediateFrameworkMessage ( OOFmsgT  inMsg,
void *  ioParam = 0 
)
protectedvirtualinherited

Send a message so any listeners can approve an action.

Must be implemented by synchronous message posting, not delayed queue as is used to provide user hooks to influence editing behaviour.

See also
dbAbstractEditHelper::CanSaveRecord
Returns
true if action approved

Definition at line 778 of file oofgui.cpp.

References dbAbstractEditHelper::SendFrameworkMessage().

Referenced by dbAbstractEditHelper::CanSaveRecord(), and dbAbstractEditHelper::ConfirmSave().

void oofSingleListener::subscribeTo ( oofBroadcaster broad)
virtualinherited
void oofSingleListener::suspendListening ( )
inherited
dbTable * dbAbstractEditHelper::table ( ) const
virtualinherited

Reimplemented from dbHelper.

Definition at line 586 of file oofgui.cpp.

References dbAbstractEditHelper::mMainTable.

Referenced by dbAbstractEditHelper::updateDerivedFieldDisplays().

void oofSingleListener::unsubscribe ( oofBroadcaster from = 0)
virtualinherited
void dbAbstractEditHelper::updateDerivedFieldDisplays ( )
virtualinherited
bool dbAbstractEditHelper::ValidateLinks ( )
protectedinherited

Check all links to see if they are validToLeaveForm, stopping at first failure.

Definition at line 717 of file oofgui.cpp.

References OOF_Dictionary::count(), dbFieldLink::highlightLink(), dbAbstractEditHelper::mLinks, and dbFieldLink::validToLeaveForm().

Referenced by dbAbstractEditHelper::CanSaveRecord().

void dbAbstractEditHelper::warnUser ( std::ostream &  os)
staticinherited

Definition at line 657 of file oofgui.cpp.

References MB_ICONEXCLAMATION, and dbConnect::raise().

Member Data Documentation

bool dbAbstractEditHelper::mAutoSaveOnMoving
protectedinherited

Definition at line 471 of file oofgui.h.

Referenced by dbAbstractEditHelper::LeaveRecord().

bool dbAbstractEditHelper::mChangingPages
protectedinherited

Definition at line 471 of file oofgui.h.

dbFieldLink* dbAbstractEditHelper::mCurrentLink
protectedinherited
OOF_Dictionary dbAbstractEditHelper::mLinks
protectedinherited
oofBroadcaster* oofSingleListener::mListensTo
protectedinherited
bool oofBroadcaster::mLostReceiversWhileBroadcasting
protectedinherited

simple flag that removeReceiver was called during nested broadcast

Definition at line 98 of file oofmsg.h.

Referenced by oofBroadcaster::broadcast(), and oofBroadcaster::removeReceiver().

dbTable* dbAbstractEditHelper::mMainTable
protectedinherited
OOFmsgT dbAbstractEditHelper::mMsgCanSaveRecord
protectedinherited
OOFmsgT dbAbstractEditHelper::mMsgChangedCurrentField
protectedinherited
OOFmsgT dbAbstractEditHelper::mMsgConfirmSave
protectedinherited
OOFmsgT dbAbstractEditHelper::mMsgEnteringAboutToLoad
protectedinherited
OOFmsgT dbAbstractEditHelper::mMsgEnteringAfterLoad
protectedinherited
unsigned long oofBroadcaster::mNestedBroadcastingDepth
protectedinherited

aid to debugging and removeReceiver

Definition at line 97 of file oofmsg.h.

Referenced by oofBroadcaster::broadcast(), oofBroadcaster::isBroadcasting(), and oofBroadcaster::removeReceiver().

bool dbAbstractEditHelper::mReadOnly
protectedinherited

Definition at line 479 of file oofgui.h.

Referenced by dbAbstractEditHelper::isReadOnly(), and dbAbstractEditHelper::readOnly().

OOF_ExpandableLongArray* oofBroadcaster::mReceivers
protectedinherited
unsigned short oofSingleListener::mSuspendCount
protectedinherited
oofBroadcaster* oofSingleListener::mSuspendedListensTo
protectedinherited

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