SystemChangeNotifier.st
author Claus Gittinger <cg@exept.de>
Thu, 11 Jul 2019 20:13:13 +0200
changeset 24419 d3a56dbbf696
parent 21274 d8206abd0aea
child 21292 21faad473411
permissions -rw-r--r--
#FEATURE by exept class: OrderedDictionary class added: #newFromObject:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21274
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
     1
"
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
     2
 COPYRIGHT (c) 2009 by eXept Software AG
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
     3
              All Rights Reserved
20513
95bba45079d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 15422
diff changeset
     4
21274
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
     5
 This software is furnished under a license and may be used
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
     6
 only in accordance with the terms of that license and with the
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
     7
 inclusion of the above copyright notice. This software may not
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
     8
 be provided or otherwise made available to, or used by, any
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
     9
 other person. No title to or ownership of the software is
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    10
 hereby transferred.
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    11
"
12221
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic' }"
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
20513
95bba45079d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 15422
diff changeset
    14
"{ NameSpace: Smalltalk }"
95bba45079d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 15422
diff changeset
    15
12221
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Object subclass:#SystemChangeNotifier
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:'silenceLevel'
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:'UniqueInstance'
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
15422
11e0080d4ef9 class: SystemChangeNotifier
Claus Gittinger <cg@exept.de>
parents: 14862
diff changeset
    20
	category:'Kernel-Classes-Support'
12221
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!SystemChangeNotifier class methodsFor:'documentation'!
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
21274
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    25
copyright
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    26
"
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    27
 COPYRIGHT (c) 2009 by eXept Software AG
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    28
              All Rights Reserved
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    29
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    30
 This software is furnished under a license and may be used
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    31
 only in accordance with the terms of that license and with the
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    32
 inclusion of the above copyright notice. This software may not
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    33
 be provided or otherwise made available to, or used by, any
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    34
 other person. No title to or ownership of the software is
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    35
 hereby transferred.
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    36
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    37
"
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    38
!
d8206abd0aea #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20513
diff changeset
    39
12221
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
documentation
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
"
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    For now, this implementation is mostly for squeak compatibility.
14862
beeba0f8b676 class: SystemChangeNotifier
Claus Gittinger <cg@exept.de>
parents: 12880
diff changeset
    43
    However, in the future, we may move the change notification code from ClassDescription to here,
12221
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    to make things easier to understand, and classDescription a little bit more lightweight.
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
"
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
! !
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
12880
48e15de4c9ab category of: #uniqueInstance
Claus Gittinger <cg@exept.de>
parents: 12367
diff changeset
    48
!SystemChangeNotifier class methodsFor:'instance creation'!
12221
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
uniqueInstance
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    "I am a singleton"
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    UniqueInstance isNil ifTrue: [UniqueInstance := self basicNew initialize].
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    ^ UniqueInstance
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    "
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
     UniqueInstance releaseAll.
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
     UniqueInstance := nil
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    "
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
! !
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
12248
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    62
!SystemChangeNotifier methodsFor:'change notifications'!
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    63
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    64
class: trait recategorizedFrom: oldCategory to:newCategory    
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    65
    "dummy for now - will write a change record eventually"
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    66
!
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    67
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    68
classAdded:aClass inCategory:aCategoryString
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    69
    "dummy for now - will write a change record eventually"
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    70
!
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    71
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    72
traitDefinitionChangedFrom:oldTrait to:newTrait
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    73
    "dummy for now - will write a change record eventually"
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    74
! !
Claus Gittinger <cg@exept.de>
parents: 12221
diff changeset
    75
12221
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
!SystemChangeNotifier methodsFor:'initialization'!
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
initialize
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
    "/ eventSource := SystemEventManager new.
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    silenceLevel := 0.
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
! !
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
!SystemChangeNotifier methodsFor:'public'!
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
doSilently: aBlock
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    "Perform the block, and ensure that no system notification are broadcasted while doing so."
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    |result|
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    silenceLevel := silenceLevel + 1.
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    [
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
        "/ temporary hack:
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
        Class withoutUpdatingChangesDo:[
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
            result := aBlock value
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
        ]
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    ] ensure: [
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
        silenceLevel > 0 ifTrue: [
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
            silenceLevel := silenceLevel - 1
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
        ]
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    ].
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   101
    ^ result.
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
!
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
isBroadcasting
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
    ^ silenceLevel = 0
12367
7edee6da9095 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12248
diff changeset
   106
!
7edee6da9095 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12248
diff changeset
   107
7edee6da9095 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12248
diff changeset
   108
noMoreNotificationsFor: aStakeHolder
7edee6da9095 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12248
diff changeset
   109
    "dummy for now "
7edee6da9095 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12248
diff changeset
   110
!
7edee6da9095 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12248
diff changeset
   111
20513
95bba45079d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 15422
diff changeset
   112
notify:aStakeHolder ofAllSystemChangesUsing:changeMessage
95bba45079d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 15422
diff changeset
   113
    "dummy for now "
95bba45079d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 15422
diff changeset
   114
!
95bba45079d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 15422
diff changeset
   115
12367
7edee6da9095 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12248
diff changeset
   116
notify:aStakeHolder ofSystemChangesOfItem:anItemSymbol change: changeTypeSymbol using: changeMessage
7edee6da9095 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 12248
diff changeset
   117
    "dummy for now "
12221
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
! !
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
!SystemChangeNotifier class methodsFor:'documentation'!
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
version_CVS
20513
95bba45079d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 15422
diff changeset
   123
    ^ '$Header$'
12221
5f71ad715ef8 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
! !
14862
beeba0f8b676 class: SystemChangeNotifier
Claus Gittinger <cg@exept.de>
parents: 12880
diff changeset
   125