Model.st
author Claus Gittinger <cg@exept.de>
Fri, 28 Jun 2019 08:49:48 +0200
changeset 4283 0d95d298a44b
parent 4269 f2ee0d19a7bc
child 4358 9299b24bc80b
permissions -rw-r--r--
#OTHER by cg self class name -> self className
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
3f9277473954 Initial revision
claus
parents:
diff changeset
     1
"
6
4ac87e6bf82f *** empty log message ***
claus
parents: 5
diff changeset
     2
 COPYRIGHT (c) 1992 by Claus Gittinger
35
f13cdd0b44c7 *** empty log message ***
claus
parents: 28
diff changeset
     3
	      All Rights Reserved
0
3f9277473954 Initial revision
claus
parents:
diff changeset
     4
3f9277473954 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
3f9277473954 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
3f9277473954 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
3f9277473954 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
3f9277473954 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
3f9277473954 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
3f9277473954 Initial revision
claus
parents:
diff changeset
    11
"
1558
1ae43779327f #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 1366
diff changeset
    12
"{ Package: 'stx:libview2' }"
1ae43779327f #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 1366
diff changeset
    13
3520
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
    14
"{ NameSpace: Smalltalk }"
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
    15
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    16
Object subclass:#Model
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
    17
	instanceVariableNames:'dependents'
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
    18
	classVariableNames:''
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
    19
	poolDictionaries:''
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
    20
	category:'Interface-Support-Models'
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    21
!
3f9277473954 Initial revision
claus
parents:
diff changeset
    22
4079
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    23
Query subclass:#ModelUpdateLockedQuery
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    24
	instanceVariableNames:''
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    25
	classVariableNames:''
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    26
	poolDictionaries:''
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    27
	privateIn:Model
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    28
!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
    29
353
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
    30
!Model class methodsFor:'documentation'!
21
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    31
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    32
copyright
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    33
"
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    34
 COPYRIGHT (c) 1992 by Claus Gittinger
35
f13cdd0b44c7 *** empty log message ***
claus
parents: 28
diff changeset
    35
	      All Rights Reserved
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    36
21
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    37
 This software is furnished under a license and may be used
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    38
 only in accordance with the terms of that license and with the
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    39
 inclusion of the above copyright notice.   This software may not
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    40
 be provided or otherwise made available to, or used by, any
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    41
 other person.  No title to or ownership of the software is
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    42
 hereby transferred.
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    43
"
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    44
!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
    45
21
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    46
documentation
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    47
"
238
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    48
    Models are things which represent information models, i.e. something
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    49
    which holds the data for user interface components and on which these operate.
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    50
    Basically, instances keep track of which components depend on them and 
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    51
    inform the dependents of any changes.
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    52
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    53
    The Model class itself is abstract and not too useful, see subclasses,
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    54
    especially, ValueHolder and SelectionInList.
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    55
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    56
    Notice:
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    57
      Actually the Model class is not really needed; since the dependency
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    58
      mechanism is inherited by Object, you can take any object as a model.
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    59
      However, instances of Model (and subclasses) keep the dependents locally
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    60
      in an instance variable; thus speeding up access a bit.
35
f13cdd0b44c7 *** empty log message ***
claus
parents: 28
diff changeset
    61
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
    62
      Model redefines the dependency methods to use non-weak dependencies
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
    63
      (in contrast to weak dependencies used by Object).  
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
    64
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
    65
    [Instance variables:]
238
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    66
        dependents      <Collection>    those objects which depend on me.
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    67
                                        To save some storage, a single dependent 
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    68
                                        is kept directly here.
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    69
                                        Otherwise, if there are multiple dependents,
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    70
                                        a collection of dependents is held here.
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
    71
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
    72
    [author:]
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 190
diff changeset
    73
        Claus Gittinger
238
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    74
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    75
    [see also:]
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    76
        ValueHolder SelectionInList
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    77
        ( introduction to view programming :html: programming/viewintro.html#MVC )
21
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
    78
"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    79
! !
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    80
3520
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
    81
!Model class methodsFor:'queries'!
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
    82
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
    83
isAbstract
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
    84
    ^ self == Model
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
    85
! !
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
    86
1244
33402f4a52ec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
    87
!Model methodsFor:'converting'!
33402f4a52ec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
    88
33402f4a52ec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
    89
skippedInLiteralEncoding
4160
b2a9377202b7 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4079
diff changeset
    90
    "define the inst-slots which are skipped when generating a literalArrayEncoding;
b2a9377202b7 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4079
diff changeset
    91
     (to skip the ones with default values.)"
2681
f3445e5a58f7 comment
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
    92
1244
33402f4a52ec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
    93
    ^ OrderedCollection with:#dependents
4160
b2a9377202b7 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4079
diff changeset
    94
b2a9377202b7 #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4079
diff changeset
    95
    "Modified (comment): / 09-08-2018 / 17:17:57 / Claus Gittinger"
1244
33402f4a52ec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
    96
! !
33402f4a52ec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
    97
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    98
!Model methodsFor:'copying'!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    99
1236
bdd6c63288bd deepCopy fix (do not copy dependents)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
   100
skipInstvarIndexInDeepCopy:index
bdd6c63288bd deepCopy fix (do not copy dependents)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
   101
    "a helper for deepCopy; only indices for which this method returns
bdd6c63288bd deepCopy fix (do not copy dependents)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
   102
     false are copied in a deep copy."
bdd6c63288bd deepCopy fix (do not copy dependents)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
   103
3034
cda16dc4b526 class: Model
Stefan Vogel <sv@exept.de>
parents: 2681
diff changeset
   104
    ^ index == 1    "/ skip dependents
21
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
   105
! !
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   106
4269
f2ee0d19a7bc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
   107
!Model methodsFor:'copying-private'!
f2ee0d19a7bc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
   108
f2ee0d19a7bc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
   109
postCopy
f2ee0d19a7bc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
   110
    "release dependents after copying"
f2ee0d19a7bc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
   111
f2ee0d19a7bc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
   112
    self dependents:nil
f2ee0d19a7bc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
   113
! !
f2ee0d19a7bc #OTHER by cg
Claus Gittinger <cg@exept.de>
parents: 4177
diff changeset
   114
83
claus
parents: 71
diff changeset
   115
!Model methodsFor:'dependents access'!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   116
83
claus
parents: 71
diff changeset
   117
addDependent:anObject
claus
parents: 71
diff changeset
   118
    "make the argument, anObject be a dependent of the receiver"
claus
parents: 71
diff changeset
   119
318
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   120
    |wasBlocked|
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   121
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   122
    wasBlocked := OperatingSystem blockInterrupts.
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   123
    [
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   124
        |deps|
83
claus
parents: 71
diff changeset
   125
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   126
        deps := dependents.
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   127
        "/
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   128
        "/ store the very first dependent directly in
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   129
        "/ the dependents instVar
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   130
        "/
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   131
        (deps isNil and:[anObject isCollection not]) ifTrue:[
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   132
            dependents := anObject
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   133
        ] ifFalse:[
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   134
            "/
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   135
            "/ store more dependents in the dependents collection
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   136
            "/
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   137
            deps isCollection ifTrue:[
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   138
                deps add:anObject
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   139
            ] ifFalse:[
353
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   140
                deps == anObject ifFalse:[
1366
7a2a23c17724 do not add nil to a Set
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   141
                    deps isNil ifTrue:[
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   142
                        dependents := IdentitySet with:anObject.
1366
7a2a23c17724 do not add nil to a Set
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   143
                    ] ifFalse:[
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   144
                        dependents := IdentitySet with:deps with:anObject.
1366
7a2a23c17724 do not add nil to a Set
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   145
                    ]
353
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   146
                ]
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   147
            ]
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   148
        ]
1558
1ae43779327f #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 1366
diff changeset
   149
    ] ensure:[
318
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   150
        wasBlocked ifFalse:[
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   151
            OperatingSystem unblockInterrupts
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   152
        ]
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   153
    ]
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   154
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   155
    "Modified: / 08-01-1997 / 23:40:30 / cg"
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   156
    "Modified (format): / 07-02-2018 / 11:27:16 / stefan"
83
claus
parents: 71
diff changeset
   157
!
claus
parents: 71
diff changeset
   158
3863
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   159
breakDependents
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   160
    "remove all dependencies from the receiver"
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   161
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   162
    dependents := nil
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   163
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   164
    "Created: / 08-02-2017 / 00:46:34 / cg"
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   165
!
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   166
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   167
dependents
771
c04519bd946f comment
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   168
    "return a Collection of dependents"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   169
720
b0e0977e1759 dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   170
    dependents isNil ifTrue:[^ #()].
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   171
    dependents isCollection ifTrue:[
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   172
        ^ dependents
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   173
    ].
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   174
    ^ IdentitySet with:dependents
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   175
771
c04519bd946f comment
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   176
    "Modified: / 26.1.1998 / 11:18:24 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   177
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   178
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   179
dependents:aCollectionOrNil
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   180
    "set the collection of dependents"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   181
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   182
    |dep|
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   183
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   184
    aCollectionOrNil size == 1 ifTrue:[
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   185
        dep := aCollectionOrNil first.
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   186
        dep isCollection ifFalse:[
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   187
            dependents := dep.
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   188
            ^ self
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   189
        ]
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   190
    ].
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   191
    dependents := aCollectionOrNil
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   192
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   193
    "Modified: / 19-04-1996 / 12:23:05 / cg"
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   194
    "Modified: / 07-02-2018 / 12:00:33 / stefan"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   195
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   196
83
claus
parents: 71
diff changeset
   197
dependentsDo:aBlock
claus
parents: 71
diff changeset
   198
    "evaluate aBlock for all of my dependents"
claus
parents: 71
diff changeset
   199
claus
parents: 71
diff changeset
   200
    |deps|
claus
parents: 71
diff changeset
   201
claus
parents: 71
diff changeset
   202
    deps := dependents.
claus
parents: 71
diff changeset
   203
    deps notNil ifTrue:[
2285
d41f74940633 enumerate a copy of the dependents in dependentsDo:
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
   204
        deps isCollection ifTrue:[
2385
f694c75f4e1a tuned #dependentsDo: if there is a single dependent
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   205
            deps size == 1 ifTrue:[
f694c75f4e1a tuned #dependentsDo: if there is a single dependent
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   206
                aBlock value:deps anElement
f694c75f4e1a tuned #dependentsDo: if there is a single dependent
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   207
            ] ifFalse:[
f694c75f4e1a tuned #dependentsDo: if there is a single dependent
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   208
                deps copy do:aBlock
f694c75f4e1a tuned #dependentsDo: if there is a single dependent
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   209
            ]
2285
d41f74940633 enumerate a copy of the dependents in dependentsDo:
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
   210
        ] ifFalse:[
d41f74940633 enumerate a copy of the dependents in dependentsDo:
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
   211
            aBlock value:deps
d41f74940633 enumerate a copy of the dependents in dependentsDo:
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
   212
        ]
83
claus
parents: 71
diff changeset
   213
    ]
claus
parents: 71
diff changeset
   214
!
claus
parents: 71
diff changeset
   215
claus
parents: 71
diff changeset
   216
removeDependent:anObject
claus
parents: 71
diff changeset
   217
    "make the argument, anObject be independent of the receiver"
claus
parents: 71
diff changeset
   218
318
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   219
    |wasBlocked|
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   220
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   221
    "/ must do this save from interrupts, since the dependents collection
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   222
    "/ is possibly accessed from multiple threads.
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   223
    "/ Used to use #valueUninterruptably here; inlined that code for slightly
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   224
    "/ faster execution.
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   225
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   226
    wasBlocked := OperatingSystem blockInterrupts.
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   227
    [
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   228
        |deps sz dep|
83
claus
parents: 71
diff changeset
   229
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   230
        deps := dependents.
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   231
        deps notNil ifTrue:[
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   232
            deps isCollection ifTrue:[
3781
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   233
                dep := deps remove:anObject ifAbsent:[].
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   234
                "if dep is nil, nothing has changed"
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   235
                dep notNil ifTrue:[
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   236
                    (sz := deps size) == 0 ifTrue:[
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   237
                        dependents := nil
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   238
                    ] ifFalse:[
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   239
                        sz == 1 ifTrue:[
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   240
                            (dep := deps first) isCollection ifFalse:[
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   241
                                dependents := dep
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   242
                            ]
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   243
                        ]
3781
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   244
                    ].
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   245
                ].
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   246
            ] ifFalse:[
353
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   247
                deps == anObject ifTrue:[
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   248
                    dependents := nil
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   249
                ]
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   250
            ]
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   251
        ]
1558
1ae43779327f #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 1366
diff changeset
   252
    ] ensure:[
318
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   253
        wasBlocked ifFalse:[
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   254
            OperatingSystem unblockInterrupts
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   255
        ]
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   256
    ]
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   257
353
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   258
    "Modified: 8.1.1997 / 23:41:39 / cg"
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   259
! !
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   260
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   261
!Model methodsFor:'dependents access (non weak)'!
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   262
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   263
addNonWeakDependent:anObject
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   264
    "make the argument, anObject be a dependent of the receiver.
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   265
     Since all dependencies are nonWeak in Model, this is simply
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   266
     forwarded to addDependent:"
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   267
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   268
    ^ self addDependent:anObject
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   269
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   270
    "Created: 19.4.1996 / 10:28:53 / cg"
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   271
!
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   272
337
e6642ba7cca9 Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 318
diff changeset
   273
interests
795
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   274
    "return a Collection of interests - empty if there is none.
337
e6642ba7cca9 Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 318
diff changeset
   275
     Here, we use the normal dependents collection for interests."
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   276
189
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   277
    ^ self dependents
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   278
795
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   279
    "Created: / 19.4.1996 / 12:28:23 / cg"
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   280
    "Modified: / 14.10.1996 / 22:19:58 / stefan"
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   281
    "Modified: / 30.1.1998 / 14:07:43 / cg"
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   282
!
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   283
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   284
nonWeakDependents
795
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   285
    "return a Collection of dependents - empty if there is none.
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   286
     Since all dependencies are nonWeak in Model, this is a dummy."
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   287
190
Claus Gittinger <cg@exept.de>
parents: 189
diff changeset
   288
    ^ self dependents
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   289
795
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   290
    "Created: / 19.4.1996 / 10:29:43 / cg"
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   291
    "Modified: / 30.1.1998 / 14:06:17 / cg"
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   292
!
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   293
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   294
removeNonWeakDependent:anObject
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   295
    "make the argument, anObject be independent of the receiver.
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   296
     Since all dependencies are nonWeak in Model, this is simply
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   297
     forwarded to removeDependent:"
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   298
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   299
    ^ self removeDependent:anObject
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   300
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   301
    "Created: 19.4.1996 / 12:19:40 / cg"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   302
! !
3f9277473954 Initial revision
claus
parents:
diff changeset
   303
4079
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   304
!Model methodsFor:'suppressing updates'!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   305
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   306
isLocked
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   307
    "ask the updateLocked query."
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   308
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   309
    ^ ModelUpdateLockedQuery isLocked:self
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   310
!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   311
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   312
withUpdatesLockedDo:aBlock
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   313
    "execute aBlock with updates to myself temporarily suppressed,
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   314
     (i.e. by answering true to the updateLocked query)
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   315
     This is a cooperative interface - i.e. possible updaters MUST
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   316
     check me via isLocked, before sending #value"
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   317
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   318
    ModelUpdateLockedQuery answer:true for:self do:aBlock
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   319
!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   320
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   321
withoutSendingUpdatesDo:aBlock
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   322
    "execute aBlock with updates to dependents temporarily suppressed
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   323
     (i.e. I will not notify the dependents during aBlock)
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   324
     Warning: 
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   325
        do not change any dependencies inside the block,
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   326
        as the original dependencies from before will be restored and such changes
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   327
        are lost then."
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   328
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   329
    |previousDependents|
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   330
4177
871e7b63f408 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4160
diff changeset
   331
    previousDependents := dependents.
4079
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   332
    [
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   333
        dependents := nil.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   334
        aBlock value
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   335
    ] ensure:[
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   336
        dependents := previousDependents
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   337
    ].
4177
871e7b63f408 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4160
diff changeset
   338
871e7b63f408 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 4160
diff changeset
   339
    "Modified: / 14-09-2018 / 14:49:47 / Stefan Vogel"
4079
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   340
! !
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   341
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   342
!Model::ModelUpdateLockedQuery class methodsFor:'documentation'!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   343
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   344
documentation
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   345
"
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   346
    this query can answer true (ie. ''isLocked'') for a particular model,
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   347
    while inside a updating block.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   348
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   349
    This is used for temporal blocking models to be changed
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   350
    (eg. to prevent cyclic updates).
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   351
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   352
    A particular application of this is found in input-field + tree selection
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   353
    combinations, where entering a new value into the field changes the treeselection,
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   354
    and also tree selection changes the input field's value.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   355
    Concrete: take a look at the XMLInspector's xpath field, which triggers a tree
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   356
    selection change, but the selection change should not backfire on the field in this
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   357
    case, whereas a regular tree-selection will change the field.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   358
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   359
    Notice:
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   360
        do NOT place the query into the general value: method of Model.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   361
        This is too expensive to be done every time.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   362
        Thus, the related models need to know about the interlocking and
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   363
        must do this individually.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   364
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   365
    see example
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   366
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   367
    [author:]
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   368
        cg
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   369
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   370
    [instance variables:]
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   371
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   372
    [class variables:]
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   373
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   374
    [see also:]
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   375
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   376
"
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   377
!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   378
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   379
example
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   380
"
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   381
    |vh1 vh2|
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   382
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   383
    vh1 := ValueHolder new.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   384
    vh1 onChangeEvaluate:[
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   385
        (vh2 isLocked) ifFalse:[
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   386
            vh2 value: #newValue 
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   387
        ].
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   388
    ].
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   389
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   390
    vh2 := ValueHolder new.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   391
    vh2 value:#oldValue.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   392
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   393
    vh2 withUpdatesLockedDo:[
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   394
        vh1 value:123.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   395
    ].
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   396
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   397
    because of the lock, the old value should still be there'.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   398
    self assert:(vh2 value == #oldValue)
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   399
"
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   400
! !
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   401
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   402
!Model::ModelUpdateLockedQuery class methodsFor:'handling'!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   403
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   404
answer:aBoolean for:aModel do:aBlock
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   405
    "evaluate aBlock, answering aBoolean if asked for the locking status of aModel"
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   406
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   407
    aBlock
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   408
        on:self 
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   409
        do:[:ex |
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   410
            ex proceedWith:(ex parameter == aModel)
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   411
        ]
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   412
! !
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   413
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   414
!Model::ModelUpdateLockedQuery class methodsFor:'queries'!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   415
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   416
isLocked:aModel
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   417
    "asking for the locking status of aModel"
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   418
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   419
    ^ self raiseRequestWith:aModel
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   420
! !
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   421
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   422
!Model::ModelUpdateLockedQuery methodsFor:'defaults'!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   423
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   424
defaultResumeValue
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   425
    ^ false
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   426
! !
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   427
353
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   428
!Model class methodsFor:'documentation'!
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   429
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   430
version
3520
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
   431
    ^ '$Header$'
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   432
! !
3520
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
   433