SystemChangeNotifier.st
author Claus Gittinger <cg@exept.de>
Mon, 12 Oct 2009 23:45:23 +0200
changeset 12248 b67d795b6669
parent 12221 5f71ad715ef8
child 12367 7edee6da9095
permissions -rw-r--r--
added: #class:recategorizedFrom:to: #classAdded:inCategory: #traitDefinitionChangedFrom:to:

"{ Package: 'stx:libbasic' }"

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

!SystemChangeNotifier class methodsFor:'documentation'!

documentation
"
    For now, this implementation is mostly for squeak compatibility.
    However, over time, we will 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 creaton'!

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
! !

!SystemChangeNotifier class methodsFor:'documentation'!

version_CVS
    ^ '$Header: /cvs/stx/stx/libbasic/SystemChangeNotifier.st,v 1.2 2009-10-12 21:45:23 cg Exp $'
! !