SystemChangeNotifier.st
author Claus Gittinger <cg@exept.de>
Mon, 03 Oct 2016 23:40:51 +0200
changeset 20513 95bba45079d3
parent 15422 11e0080d4ef9
child 20579 9add81aadb7a
child 21274 d8206abd0aea
permissions -rw-r--r--
#DOCUMENTATION by cg class: SystemChangeNotifier added: #notify:ofAllSystemChangesUsing:

"{ Encoding: utf8 }"

"{ Package: 'stx:libbasic' }"

"{ NameSpace: Smalltalk }"

Object subclass:#SystemChangeNotifier
	instanceVariableNames:'silenceLevel'
	classVariableNames:'UniqueInstance'
	poolDictionaries:''
	category:'Kernel-Classes-Support'
!

!SystemChangeNotifier class methodsFor:'documentation'!

documentation
"
    For now, this implementation is mostly for squeak compatibility.
    However, in the future, we may move the change notification code from ClassDescription to here,
    to make things easier to understand, and classDescription a little bit more lightweight.
"
! !

!SystemChangeNotifier class methodsFor:'instance creation'!

uniqueInstance
    "I am a singleton"

    UniqueInstance isNil ifTrue: [UniqueInstance := self basicNew initialize].
    ^ UniqueInstance

    "
     UniqueInstance releaseAll.
     UniqueInstance := nil
    "
! !

!SystemChangeNotifier methodsFor:'change notifications'!

class: trait recategorizedFrom: oldCategory to:newCategory    
    "dummy for now - will write a change record eventually"
!

classAdded:aClass inCategory:aCategoryString
    "dummy for now - will write a change record eventually"
!

traitDefinitionChangedFrom:oldTrait to:newTrait
    "dummy for now - will write a change record eventually"
! !

!SystemChangeNotifier methodsFor:'initialization'!

initialize
    "/ eventSource := SystemEventManager new.
    silenceLevel := 0.
! !

!SystemChangeNotifier methodsFor:'public'!

doSilently: aBlock
    "Perform the block, and ensure that no system notification are broadcasted while doing so."

    |result|

    silenceLevel := silenceLevel + 1.
    [
        "/ temporary hack:
        Class withoutUpdatingChangesDo:[
            result := aBlock value
        ]
    ] ensure: [
        silenceLevel > 0 ifTrue: [
            silenceLevel := silenceLevel - 1
        ]
    ].
    ^ result.
!

isBroadcasting
    ^ silenceLevel = 0
!

noMoreNotificationsFor: aStakeHolder
    "dummy for now "
!

notify:aStakeHolder ofAllSystemChangesUsing:changeMessage
    "dummy for now "
!

notify:aStakeHolder ofSystemChangesOfItem:anItemSymbol change: changeTypeSymbol using: changeMessage
    "dummy for now "
! !

!SystemChangeNotifier class methodsFor:'documentation'!

version_CVS
    ^ '$Header$'
! !