AspectAdaptor.st
author ca
Wed, 21 Feb 2007 13:07:21 +0100
changeset 2286 1c46b5e812bc
parent 789 98a12d3c3bee
child 2742 cfd86b0441ae
permissions -rw-r--r--
Bug 580-STX fixed; check whether target is nil
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
74
claus
parents: 71
diff changeset
     1
"
claus
parents: 71
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents: 71
diff changeset
     3
	      All Rights Reserved
claus
parents: 71
diff changeset
     4
claus
parents: 71
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents: 71
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents: 71
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents: 71
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents: 71
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents: 71
diff changeset
    10
 hereby transferred.
claus
parents: 71
diff changeset
    11
"
2286
1c46b5e812bc Bug 580-STX fixed; check whether target is nil
ca
parents: 789
diff changeset
    12
"{ Package: 'stx:libview2' }"
74
claus
parents: 71
diff changeset
    13
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
    14
ProtocolAdaptor subclass:#AspectAdaptor
217
08a8e312d0e4 commentary
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    15
	instanceVariableNames:'myAspect getMsg putMsg'
08a8e312d0e4 commentary
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    16
	classVariableNames:''
08a8e312d0e4 commentary
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    17
	poolDictionaries:''
08a8e312d0e4 commentary
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    18
	category:'Interface-Support-Models'
69
claus
parents:
diff changeset
    19
!
claus
parents:
diff changeset
    20
claus
parents:
diff changeset
    21
!AspectAdaptor class methodsFor:'documentation'!
claus
parents:
diff changeset
    22
claus
parents:
diff changeset
    23
copyright
claus
parents:
diff changeset
    24
"
claus
parents:
diff changeset
    25
 COPYRIGHT (c) 1995 by Claus Gittinger
71
claus
parents: 69
diff changeset
    26
	      All Rights Reserved
69
claus
parents:
diff changeset
    27
claus
parents:
diff changeset
    28
 This software is furnished under a license and may be used
claus
parents:
diff changeset
    29
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
    31
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
    32
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    33
 hereby transferred.
claus
parents:
diff changeset
    34
"
claus
parents:
diff changeset
    35
!
claus
parents:
diff changeset
    36
claus
parents:
diff changeset
    37
documentation
claus
parents:
diff changeset
    38
"
claus
parents:
diff changeset
    39
    an AspectAdaptor forwards updates and change messages
claus
parents:
diff changeset
    40
    from/to a complex model.
claus
parents:
diff changeset
    41
claus
parents:
diff changeset
    42
    Consider the case where editFields are required for the
789
98a12d3c3bee Fix typo.
Stefan Vogel <sv@exept.de>
parents: 448
diff changeset
    43
    elements (instance variables) of a compound object:
238
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    44
    - without an aspect adaptor, you needed to copy the individual
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    45
      values out-of the object and move these into multiple valueHolders.
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    46
      Then, let the editFields modify the valueHolders contents and
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    47
      finally, fetch the values and put them back into the compound object.
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    48
69
claus
parents:
diff changeset
    49
    An aspectAdaptor makes this easier, by playing model with
85
claus
parents: 83
diff changeset
    50
    value/value: symbols towards the editField, and forwarding changes and
789
98a12d3c3bee Fix typo.
Stefan Vogel <sv@exept.de>
parents: 448
diff changeset
    51
    updates to/from the compound object using different aspect symbols
238
a179b5d6152e checkin from browser
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    52
    and access messages.
69
claus
parents:
diff changeset
    53
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    54
    Notice: 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    55
        this class was implemented using protocol information
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    56
        from alpha testers - it may not be complete or compatible to
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    57
        the corresponding ST-80 class. 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    58
        If you encounter any incompatibilities, please forward a note 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    59
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
217
08a8e312d0e4 commentary
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    60
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
    61
    [author:]
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
    62
        Claus Gittinger
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 217
diff changeset
    63
217
08a8e312d0e4 commentary
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    64
    [see also:]
08a8e312d0e4 commentary
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    65
        ValueHolder Model
69
claus
parents:
diff changeset
    66
"
claus
parents:
diff changeset
    67
!
claus
parents:
diff changeset
    68
claus
parents:
diff changeset
    69
examples
claus
parents:
diff changeset
    70
"
claus
parents:
diff changeset
    71
    a dialog on a points x/y coordinates:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    72
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    73
        |dialog data f|
69
claus
parents:
diff changeset
    74
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    75
        data := 0@0.
69
claus
parents:
diff changeset
    76
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    77
        dialog := DialogBox new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    78
        dialog addTextLabel:'x:'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    79
        f := dialog addInputFieldOn:(AspectAdaptor new
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    80
                                        subject:data; 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    81
                                        accessWith:#x 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    82
                                        assignWith:#x:).
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    83
        f converter:(PrintConverter new initForNumber).
69
claus
parents:
diff changeset
    84
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    85
        dialog addTextLabel:'y:'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    86
        f := dialog addInputFieldOn:(AspectAdaptor new
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    87
                                        subject:data; 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    88
                                        forAspect:#y).
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    89
        f converter:(PrintConverter new initForNumber).
69
claus
parents:
diff changeset
    90
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    91
        dialog addOkButton.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    92
        data inspect.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    93
        dialog open.
69
claus
parents:
diff changeset
    94
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    95
        dialog accepted ifTrue:[
268
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
    96
            Transcript showCR:'data now: ' , data printString
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    97
        ]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    98
                                                                        [exEnd]
69
claus
parents:
diff changeset
    99
claus
parents:
diff changeset
   100
claus
parents:
diff changeset
   101
    a dialog on a four-field complex model:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   102
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   103
        |dialog data dataModel|
69
claus
parents:
diff changeset
   104
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   105
        data := #('hello' 'one' 'two' 'three').
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   106
        dataModel := Plug new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   107
        dataModel respondTo:#field1 with:[data at:1].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   108
        dataModel respondTo:#field2 with:[data at:2].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   109
        dataModel respondTo:#field3 with:[data at:3].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   110
        dataModel respondTo:#field4 with:[data at:4].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   111
        dataModel respondTo:#field1: with:[:arg | data at:1 put:arg].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   112
        dataModel respondTo:#field2: with:[:arg | data at:2 put:arg].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   113
        dataModel respondTo:#field3: with:[:arg | data at:3 put:arg].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   114
        dataModel respondTo:#field4: with:[:arg | data at:4 put:arg].
69
claus
parents:
diff changeset
   115
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   116
        dialog := DialogBox new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   117
        dialog addTextLabel:'1:'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   118
        dialog addInputFieldOn:(AspectAdaptor new
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   119
                                        subject:dataModel; 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   120
                                        accessWith:#field1
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   121
                                        assignWith:#field1:). 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   122
        dialog addTextLabel:'2:'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   123
        dialog addInputFieldOn:(AspectAdaptor new
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   124
                                        subject:dataModel; 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   125
                                        forAspect:#field2).
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   126
        dialog addTextLabel:'3:'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   127
        dialog addInputFieldOn:(AspectAdaptor new
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   128
                                        subject:dataModel; 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   129
                                        accessWith:#field3
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   130
                                        assignWith:#field3:
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   131
                                        aspect:#field3). 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   132
        dialog addTextLabel:'4:'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   133
        dialog addInputFieldOn:(AspectAdaptor new
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   134
                                        subject:dataModel; 
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   135
                                        forAspect:#field4).
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   136
        dialog addOkButton.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   137
        dataModel inspect.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   138
        dialog open.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   139
        dialog accepted ifTrue:[
268
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 238
diff changeset
   140
            Transcript showCR:'data now: ' , data printString
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   141
        ]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   142
                                                                        [exEnd]
69
claus
parents:
diff changeset
   143
"
claus
parents:
diff changeset
   144
! !
claus
parents:
diff changeset
   145
claus
parents:
diff changeset
   146
!AspectAdaptor class methodsFor:'instance creation'!
claus
parents:
diff changeset
   147
claus
parents:
diff changeset
   148
accessWith:getSelector assignWith:putSelector 
83
claus
parents: 74
diff changeset
   149
    "create and return an adaptor which uses getSelector to fetch a value
claus
parents: 74
diff changeset
   150
     and setSelector to change it."
claus
parents: 74
diff changeset
   151
69
claus
parents:
diff changeset
   152
    ^ (self new) accessWith:getSelector assignWith:putSelector
85
claus
parents: 83
diff changeset
   153
!
claus
parents: 83
diff changeset
   154
439
00d7fa5cf3f0 checkin from browser
ca
parents: 409
diff changeset
   155
forAspect:anAspect
00d7fa5cf3f0 checkin from browser
ca
parents: 409
diff changeset
   156
    "create and return a new adaptor, which forwards requests
00d7fa5cf3f0 checkin from browser
ca
parents: 409
diff changeset
   157
     to anObject, using anAspect as get-selector and anAspect-colon as putSelector
00d7fa5cf3f0 checkin from browser
ca
parents: 409
diff changeset
   158
     for access. The returned object can be used in place of a ValueHolder"
00d7fa5cf3f0 checkin from browser
ca
parents: 409
diff changeset
   159
00d7fa5cf3f0 checkin from browser
ca
parents: 409
diff changeset
   160
    ^ self new forAspect:anAspect
00d7fa5cf3f0 checkin from browser
ca
parents: 409
diff changeset
   161
00d7fa5cf3f0 checkin from browser
ca
parents: 409
diff changeset
   162
    "Modified: 22.1.1997 / 12:00:42 / cg"
00d7fa5cf3f0 checkin from browser
ca
parents: 409
diff changeset
   163
!
00d7fa5cf3f0 checkin from browser
ca
parents: 409
diff changeset
   164
85
claus
parents: 83
diff changeset
   165
subject:anObject sendsUpdates:aBoolean accessWith:getSel assignWith:putSel aspect:aspect
379
62b71a8294a3 comments
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   166
    "create and return a new adaptor, which forwards requests
62b71a8294a3 comments
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   167
     to anObject, using getSel/putSel for access.
62b71a8294a3 comments
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   168
     The returned object can be used in place of a ValueHolder"
62b71a8294a3 comments
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   169
85
claus
parents: 83
diff changeset
   170
    ^ (self subject:anObject sendsUpdates:aBoolean) 
379
62b71a8294a3 comments
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   171
                accessWith:getSel assignWith:putSel aspect:aspect
62b71a8294a3 comments
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   172
62b71a8294a3 comments
Claus Gittinger <cg@exept.de>
parents: 268
diff changeset
   173
    "Modified: 22.1.1997 / 12:00:42 / cg"
69
claus
parents:
diff changeset
   174
! !
claus
parents:
diff changeset
   175
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   176
!AspectAdaptor methodsFor:'accessing-spec'!
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
accessWith:getSelector assignWith:putSelector
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   179
    "setup the recevier to use getSelector to fetch a value
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   180
     and putSelector to change it."
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   181
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   182
    getMsg := getSelector.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   183
    putMsg := putSelector
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   184
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   185
    "Modified: 22.1.1997 / 18:28:46 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   186
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   187
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   188
accessWith:getSelector assignWith:putSelector aspect:aspectSymbol
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   189
    "setup the recevier to use getSelector to fetch a value
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   190
     and putSelector to change it."
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   191
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   192
    getMsg := getSelector.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   193
    putMsg := putSelector.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   194
    myAspect := aspectSymbol
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   195
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   196
    "Modified: 22.1.1997 / 18:28:51 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   197
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   198
409
391a714f95e4 added #aspect:
ca
parents: 381
diff changeset
   199
aspect:aSelector
391a714f95e4 added #aspect:
ca
parents: 381
diff changeset
   200
    "set the adapters change aspect - this is the aspect of the update message,
391a714f95e4 added #aspect:
ca
parents: 381
diff changeset
   201
     on which the adaptor reacts"
391a714f95e4 added #aspect:
ca
parents: 381
diff changeset
   202
391a714f95e4 added #aspect:
ca
parents: 381
diff changeset
   203
    myAspect := aSelector.
391a714f95e4 added #aspect:
ca
parents: 381
diff changeset
   204
!
391a714f95e4 added #aspect:
ca
parents: 381
diff changeset
   205
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   206
forAspect
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   207
    "get the adapters aspect - if none was defined, the getMsg is returned"
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   208
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   209
    myAspect isNil ifTrue:[
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   210
        ^ getMsg
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   211
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   212
    ^ myAspect
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   213
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   214
    "Modified: 22.1.1997 / 18:27:24 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   215
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   216
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   217
forAspect:aSelector
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   218
    "set the adapters aspect - this sets both the get- and put-Messages
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   219
     (the putMessage is the aspect with a colon)"
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   220
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   221
    getMsg := myAspect := aSelector.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   222
    putMsg := (aSelector , ':') asSymbol.
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   223
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   224
    "Modified: 22.1.1997 / 18:29:05 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   225
! !
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   226
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   227
!AspectAdaptor methodsFor:'accessing-value'!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   228
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   229
setValue:newValue
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   230
    "set the value - this forwards a putMessage to the target"
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   231
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   232
    |target oldValue|
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   233
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   234
    target := super value.
2286
1c46b5e812bc Bug 580-STX fixed; check whether target is nil
ca
parents: 789
diff changeset
   235
    target isNil ifTrue:[^ nil].
1c46b5e812bc Bug 580-STX fixed; check whether target is nil
ca
parents: 789
diff changeset
   236
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   237
    oldValue := target perform:getMsg.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   238
    oldValue ~~ newValue ifTrue:[
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   239
        target perform:putMsg with:newValue.
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   240
    ]
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   241
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   242
    "Modified: 22.1.1997 / 18:28:40 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   243
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   244
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   245
value
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   246
    "translate a query for my value from my user
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   247
     into an aspect access towards my subject"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   248
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   249
    |target|
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   250
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   251
    target := super value.
409
391a714f95e4 added #aspect:
ca
parents: 381
diff changeset
   252
    target isNil ifTrue:[^ nil].
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   253
    ^ target perform:getMsg
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   254
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   255
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   256
value:newValue
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   257
    "set the value - this forwards a putMessage to the target
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   258
     and sends out a changeNotification if the value did really change."
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   259
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   260
    |target oldValue|
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   261
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   262
    target := super value.
2286
1c46b5e812bc Bug 580-STX fixed; check whether target is nil
ca
parents: 789
diff changeset
   263
    target isNil ifTrue:[^ nil].
1c46b5e812bc Bug 580-STX fixed; check whether target is nil
ca
parents: 789
diff changeset
   264
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   265
    oldValue := target perform:getMsg.
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   266
    oldValue ~~ newValue ifTrue:[
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   267
        target perform:putMsg with:newValue.
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   268
        subjectSendsUpdates ifFalse:[
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   269
            self changed:#value
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   270
        ]
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   271
    ]
381
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   272
b8126729b7a4 commentary
Claus Gittinger <cg@exept.de>
parents: 379
diff changeset
   273
    "Modified: 22.1.1997 / 18:29:59 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   274
! !
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   275
69
claus
parents:
diff changeset
   276
!AspectAdaptor methodsFor:'change & update'!
claus
parents:
diff changeset
   277
claus
parents:
diff changeset
   278
update:something with:aParameter from:changedObject
claus
parents:
diff changeset
   279
    "translate an update from the model into a #value-change
claus
parents:
diff changeset
   280
     via my depenedents ..."
claus
parents:
diff changeset
   281
448
5a9fb44b4a3f *** empty log message ***
ca
parents: 439
diff changeset
   282
    ((changedObject == subject and:[something == self forAspect])
69
claus
parents:
diff changeset
   283
    or:[changedObject == subjectChannel]) ifTrue:[
448
5a9fb44b4a3f *** empty log message ***
ca
parents: 439
diff changeset
   284
        self changed:#value
69
claus
parents:
diff changeset
   285
    ].
claus
parents:
diff changeset
   286
! !
claus
parents:
diff changeset
   287
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   288
!AspectAdaptor class methodsFor:'documentation'!
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   289
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   290
version
2286
1c46b5e812bc Bug 580-STX fixed; check whether target is nil
ca
parents: 789
diff changeset
   291
    ^ '$Header: /cvs/stx/stx/libview2/AspectAdaptor.st,v 1.21 2007-02-21 12:07:21 ca Exp $'
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   292
! !