Model.st
author Claus Gittinger <cg@exept.de>
Thu, 14 Jun 2018 00:19:41 +0200
changeset 4125 7d349e2afa0e
parent 4079 294c4b32e0d0
child 4160 b2a9377202b7
permissions -rw-r--r--
#BUGFIX by cg class: DragAndDropManager changed: #buttonRelease:x:y:view: care for rootView
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
2681
f3445e5a58f7 comment
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
    90
    "return a Collection with elements which are skipped in the encoding"
f3445e5a58f7 comment
Claus Gittinger <cg@exept.de>
parents: 2385
diff changeset
    91
1244
33402f4a52ec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
    92
    ^ OrderedCollection with:#dependents
33402f4a52ec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
    93
! !
33402f4a52ec checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1236
diff changeset
    94
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    95
!Model methodsFor:'copying'!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    96
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    97
postCopy
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    98
    "release dependents after copying"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    99
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   100
    self dependents:nil
1236
bdd6c63288bd deepCopy fix (do not copy dependents)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
   101
!
bdd6c63288bd deepCopy fix (do not copy dependents)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
   102
bdd6c63288bd deepCopy fix (do not copy dependents)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
   103
skipInstvarIndexInDeepCopy:index
bdd6c63288bd deepCopy fix (do not copy dependents)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
   104
    "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
   105
     false are copied in a deep copy."
bdd6c63288bd deepCopy fix (do not copy dependents)
Claus Gittinger <cg@exept.de>
parents: 795
diff changeset
   106
3034
cda16dc4b526 class: Model
Stefan Vogel <sv@exept.de>
parents: 2681
diff changeset
   107
    ^ index == 1    "/ skip dependents
21
66b31c91177f *** empty log message ***
claus
parents: 10
diff changeset
   108
! !
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   109
83
claus
parents: 71
diff changeset
   110
!Model methodsFor:'dependents access'!
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   111
83
claus
parents: 71
diff changeset
   112
addDependent:anObject
claus
parents: 71
diff changeset
   113
    "make the argument, anObject be a dependent of the receiver"
claus
parents: 71
diff changeset
   114
318
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   115
    |wasBlocked|
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   116
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   117
    wasBlocked := OperatingSystem blockInterrupts.
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   118
    [
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   119
        |deps|
83
claus
parents: 71
diff changeset
   120
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   121
        deps := dependents.
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   122
        "/
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   123
        "/ store the very first dependent directly in
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   124
        "/ the dependents instVar
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   125
        "/
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   126
        (deps isNil and:[anObject isCollection not]) ifTrue:[
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   127
            dependents := anObject
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   128
        ] ifFalse:[
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   129
            "/
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   130
            "/ store more dependents in the dependents collection
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   131
            "/
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   132
            deps isCollection ifTrue:[
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   133
                deps add:anObject
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   134
            ] ifFalse:[
353
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   135
                deps == anObject ifFalse:[
1366
7a2a23c17724 do not add nil to a Set
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   136
                    deps isNil ifTrue:[
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   137
                        dependents := IdentitySet with:anObject.
1366
7a2a23c17724 do not add nil to a Set
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   138
                    ] ifFalse:[
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   139
                        dependents := IdentitySet with:deps with:anObject.
1366
7a2a23c17724 do not add nil to a Set
Claus Gittinger <cg@exept.de>
parents: 1244
diff changeset
   140
                    ]
353
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   141
                ]
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   142
            ]
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   143
        ]
1558
1ae43779327f #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 1366
diff changeset
   144
    ] ensure:[
318
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   145
        wasBlocked ifFalse:[
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   146
            OperatingSystem unblockInterrupts
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   147
        ]
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   148
    ]
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   149
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   150
    "Modified: / 08-01-1997 / 23:40:30 / cg"
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   151
    "Modified (format): / 07-02-2018 / 11:27:16 / stefan"
83
claus
parents: 71
diff changeset
   152
!
claus
parents: 71
diff changeset
   153
3863
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   154
breakDependents
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   155
    "remove all dependencies from the receiver"
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   156
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   157
    dependents := nil
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   158
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   159
    "Created: / 08-02-2017 / 00:46:34 / cg"
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   160
!
caa2b65ccae0 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 3781
diff changeset
   161
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   162
dependents
771
c04519bd946f comment
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   163
    "return a Collection of dependents"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   164
720
b0e0977e1759 dependents now always returns a collection
Claus Gittinger <cg@exept.de>
parents: 353
diff changeset
   165
    dependents isNil ifTrue:[^ #()].
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   166
    dependents isCollection ifTrue:[
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   167
        ^ dependents
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   168
    ].
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   169
    ^ IdentitySet with:dependents
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   170
771
c04519bd946f comment
Claus Gittinger <cg@exept.de>
parents: 720
diff changeset
   171
    "Modified: / 26.1.1998 / 11:18:24 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   172
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   173
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   174
dependents:aCollectionOrNil
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   175
    "set the collection of dependents"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   176
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   177
    |dep|
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   178
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   179
    aCollectionOrNil size == 1 ifTrue:[
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   180
        dep := aCollectionOrNil first.
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   181
        dep isCollection ifFalse:[
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   182
            dependents := dep.
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   183
            ^ self
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   184
        ]
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   185
    ].
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   186
    dependents := aCollectionOrNil
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   187
4062
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   188
    "Modified: / 19-04-1996 / 12:23:05 / cg"
d1b18ea171a9 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3863
diff changeset
   189
    "Modified: / 07-02-2018 / 12:00:33 / stefan"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   190
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   191
83
claus
parents: 71
diff changeset
   192
dependentsDo:aBlock
claus
parents: 71
diff changeset
   193
    "evaluate aBlock for all of my dependents"
claus
parents: 71
diff changeset
   194
claus
parents: 71
diff changeset
   195
    |deps|
claus
parents: 71
diff changeset
   196
claus
parents: 71
diff changeset
   197
    deps := dependents.
claus
parents: 71
diff changeset
   198
    deps notNil ifTrue:[
2285
d41f74940633 enumerate a copy of the dependents in dependentsDo:
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
   199
        deps isCollection ifTrue:[
2385
f694c75f4e1a tuned #dependentsDo: if there is a single dependent
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   200
            deps size == 1 ifTrue:[
f694c75f4e1a tuned #dependentsDo: if there is a single dependent
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   201
                aBlock value:deps anElement
f694c75f4e1a tuned #dependentsDo: if there is a single dependent
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   202
            ] ifFalse:[
f694c75f4e1a tuned #dependentsDo: if there is a single dependent
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   203
                deps copy do:aBlock
f694c75f4e1a tuned #dependentsDo: if there is a single dependent
Claus Gittinger <cg@exept.de>
parents: 2285
diff changeset
   204
            ]
2285
d41f74940633 enumerate a copy of the dependents in dependentsDo:
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
   205
        ] ifFalse:[
d41f74940633 enumerate a copy of the dependents in dependentsDo:
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
   206
            aBlock value:deps
d41f74940633 enumerate a copy of the dependents in dependentsDo:
Claus Gittinger <cg@exept.de>
parents: 2052
diff changeset
   207
        ]
83
claus
parents: 71
diff changeset
   208
    ]
claus
parents: 71
diff changeset
   209
!
claus
parents: 71
diff changeset
   210
claus
parents: 71
diff changeset
   211
removeDependent:anObject
claus
parents: 71
diff changeset
   212
    "make the argument, anObject be independent of the receiver"
claus
parents: 71
diff changeset
   213
318
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   214
    |wasBlocked|
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   215
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   216
    "/ 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
   217
    "/ is possibly accessed from multiple threads.
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   218
    "/ 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
   219
    "/ faster execution.
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
    wasBlocked := OperatingSystem blockInterrupts.
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   222
    [
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   223
        |deps sz dep|
83
claus
parents: 71
diff changeset
   224
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   225
        deps := dependents.
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   226
        deps notNil ifTrue:[
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   227
            deps isCollection ifTrue:[
3781
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   228
                dep := deps remove:anObject ifAbsent:[].
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   229
                "if dep is nil, nothing has changed"
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   230
                dep notNil ifTrue:[
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   231
                    (sz := deps size) == 0 ifTrue:[
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   232
                        dependents := nil
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   233
                    ] ifFalse:[
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   234
                        sz == 1 ifTrue:[
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   235
                            (dep := deps first) isCollection ifFalse:[
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   236
                                dependents := dep
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   237
                            ]
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   238
                        ]
3781
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   239
                    ].
2386ff0bc070 #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3520
diff changeset
   240
                ].
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   241
            ] ifFalse:[
353
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   242
                deps == anObject ifTrue:[
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   243
                    dependents := nil
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   244
                ]
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   245
            ]
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   246
        ]
1558
1ae43779327f #valueNowOrOnUnwindDo: -> #ensure:
Claus Gittinger <cg@exept.de>
parents: 1366
diff changeset
   247
    ] ensure:[
318
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   248
        wasBlocked ifFalse:[
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   249
            OperatingSystem unblockInterrupts
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   250
        ]
097d70e8163f use inline interrupt blocking in dependents acces methods.
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   251
    ]
163
80f4fe3bcc71 care for interrupts while adding/removing dependents
Claus Gittinger <cg@exept.de>
parents: 153
diff changeset
   252
353
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   253
    "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
   254
! !
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   255
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   256
!Model methodsFor:'dependents access (non weak)'!
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   257
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   258
addNonWeakDependent:anObject
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   259
    "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
   260
     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
   261
     forwarded to addDependent:"
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
    ^ self addDependent:anObject
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   264
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   265
    "Created: 19.4.1996 / 10:28:53 / cg"
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   266
!
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   267
337
e6642ba7cca9 Rename misspelled "interrest" to "interest".
Stefan Vogel <sv@exept.de>
parents: 318
diff changeset
   268
interests
795
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   269
    "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
   270
     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
   271
189
Claus Gittinger <cg@exept.de>
parents: 188
diff changeset
   272
    ^ self dependents
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   273
795
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   274
    "Created: / 19.4.1996 / 12:28:23 / cg"
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   275
    "Modified: / 14.10.1996 / 22:19:58 / stefan"
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   276
    "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
   277
!
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   278
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   279
nonWeakDependents
795
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   280
    "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
   281
     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
   282
190
Claus Gittinger <cg@exept.de>
parents: 189
diff changeset
   283
    ^ self dependents
188
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   284
795
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   285
    "Created: / 19.4.1996 / 10:29:43 / cg"
f79766570dd7 #nonWeakDependents always returns a collection
Claus Gittinger <cg@exept.de>
parents: 771
diff changeset
   286
    "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
   287
!
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   288
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   289
removeNonWeakDependent:anObject
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   290
    "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
   291
     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
   292
     forwarded to removeDependent:"
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
    ^ self removeDependent:anObject
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   295
38e92ed0e1b9 interrest changes in model (nonWeak stuff)
Claus Gittinger <cg@exept.de>
parents: 163
diff changeset
   296
    "Created: 19.4.1996 / 12:19:40 / cg"
0
3f9277473954 Initial revision
claus
parents:
diff changeset
   297
! !
3f9277473954 Initial revision
claus
parents:
diff changeset
   298
4079
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   299
!Model methodsFor:'suppressing updates'!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   300
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   301
isLocked
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   302
    "ask the updateLocked query."
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   303
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   304
    ^ ModelUpdateLockedQuery isLocked:self
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
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   307
withUpdatesLockedDo:aBlock
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   308
    "execute aBlock with updates to myself temporarily suppressed,
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   309
     (i.e. by answering true to the updateLocked query)
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   310
     This is a cooperative interface - i.e. possible updaters MUST
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   311
     check me via isLocked, before sending #value"
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   312
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   313
    ModelUpdateLockedQuery answer:true for:self do:aBlock
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   314
!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   315
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   316
withoutSendingUpdatesDo:aBlock
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   317
    "execute aBlock with updates to dependents temporarily suppressed
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   318
     (i.e. I will not notify the dependents during aBlock)
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   319
     Warning: 
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   320
        do not change any dependencies inside the block,
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   321
        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
   322
        are lost then."
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   323
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   324
    |previousDependents|
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   325
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   326
    [
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   327
        previousDependents := dependents.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   328
        dependents := nil.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   329
        aBlock value
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   330
    ] ensure:[
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   331
        dependents := previousDependents
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
! !
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   334
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   335
!Model::ModelUpdateLockedQuery class methodsFor:'documentation'!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   336
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   337
documentation
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   338
"
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   339
    this query can answer true (ie. ''isLocked'') for a particular model,
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   340
    while inside a updating block.
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
    This is used for temporal blocking models to be changed
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   343
    (eg. to prevent cyclic updates).
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   344
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   345
    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
   346
    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
   347
    and also tree selection changes the input field's value.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   348
    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
   349
    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
   350
    case, whereas a regular tree-selection will change the field.
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
    Notice:
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   353
        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
   354
        This is too expensive to be done every time.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   355
        Thus, the related models need to know about the interlocking and
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   356
        must do this individually.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   357
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   358
    see example
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   359
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   360
    [author:]
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   361
        cg
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   362
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   363
    [instance variables:]
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
    [class variables:]
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
    [see also:]
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   368
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
!
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
example
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
    |vh1 vh2|
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
    vh1 := ValueHolder new.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   377
    vh1 onChangeEvaluate:[
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   378
        (vh2 isLocked) ifFalse:[
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   379
            vh2 value: #newValue 
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
    ].
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
    vh2 := ValueHolder new.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   384
    vh2 value:#oldValue.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   385
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   386
    vh2 withUpdatesLockedDo:[
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   387
        vh1 value:123.
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
    because of the lock, the old value should still be there'.
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   391
    self assert:(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
! !
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   394
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   395
!Model::ModelUpdateLockedQuery class methodsFor:'handling'!
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
answer:aBoolean for:aModel do:aBlock
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   398
    "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
   399
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   400
    aBlock
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   401
        on:self 
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   402
        do:[:ex |
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   403
            ex proceedWith:(ex parameter == aModel)
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   404
        ]
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   405
! !
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
!Model::ModelUpdateLockedQuery class methodsFor:'queries'!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   408
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   409
isLocked:aModel
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   410
    "asking for the locking status of 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
    ^ self raiseRequestWith:aModel
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
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   415
!Model::ModelUpdateLockedQuery methodsFor:'defaults'!
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   416
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   417
defaultResumeValue
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   418
    ^ false
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   419
! !
294c4b32e0d0 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 4062
diff changeset
   420
353
e9071756b6a7 oops - removeDependent: removed the dependent, even if
Claus Gittinger <cg@exept.de>
parents: 337
diff changeset
   421
!Model class methodsFor:'documentation'!
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   422
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   423
version
3520
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
   424
    ^ '$Header$'
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   425
! !
3520
c118d354c76f #DOCUMENTATION
Claus Gittinger <cg@exept.de>
parents: 3034
diff changeset
   426