PluggableAdaptor.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 15 Mar 2014 14:58:13 +0100
changeset 3311 514c65e7f366
parent 3310 b0eef4f85fc9
child 3440 4db110335eaa
permissions -rw-r--r--
Workaround for stc bug, sigh.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
75
claus
parents:
diff changeset
     1
"
claus
parents:
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
claus
parents:
diff changeset
     3
	      All Rights Reserved
claus
parents:
diff changeset
     4
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents:
diff changeset
    10
 hereby transferred.
claus
parents:
diff changeset
    11
"
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1127
diff changeset
    12
"{ Package: 'stx:libview2' }"
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1127
diff changeset
    13
75
claus
parents:
diff changeset
    14
ValueModel subclass:#PluggableAdaptor
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    15
	instanceVariableNames:'model getBlock putBlock updateBlock'
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    16
	classVariableNames:''
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    17
	poolDictionaries:''
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    18
	category:'Interface-Support-Models'
75
claus
parents:
diff changeset
    19
!
claus
parents:
diff changeset
    20
claus
parents:
diff changeset
    21
!PluggableAdaptor 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
claus
parents:
diff changeset
    26
	      All Rights Reserved
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
    Allows forwarding of value/value:/change messages via blocks.
claus
parents:
diff changeset
    40
    Kind of what ST/X always did ....
claus
parents:
diff changeset
    41
claus
parents:
diff changeset
    42
    PluggableAdaptor is the most general of the adaptor models -
claus
parents:
diff changeset
    43
    any other adapter can be simulated. However, they incur certain
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
    44
    overhead and complexity.
82
claus
parents: 79
diff changeset
    45
    Therefore, in many situations, an AspectAdaptor is the better choice.
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    46
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
    47
    Notice:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    48
        this class was implemented using protocol information
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    49
        from alpha testers - it may not be complete or compatible to
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
    50
        the corresponding ST-80 class.
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
    51
        If you encounter any incompatibilities, please forward a note
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    52
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    53
223
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    54
    [author:]
b65dc250db8d documentation
Claus Gittinger <cg@exept.de>
parents: 129
diff changeset
    55
        Claus Gittinger
76
claus
parents: 75
diff changeset
    56
"
claus
parents: 75
diff changeset
    57
!
75
claus
parents:
diff changeset
    58
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
    59
examples
76
claus
parents: 75
diff changeset
    60
"
claus
parents: 75
diff changeset
    61
    an adaptor for the variable x:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    62
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    63
        |m x t|
75
claus
parents:
diff changeset
    64
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    65
        m := (PluggableAdaptor new)
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    66
                getBlock:[:m | x]
268
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    67
                putBlock:[:m :newValue | x := newValue. Transcript showCR:x]
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
    68
                updateBlock:[:m :aspect :param | Transcript showCR:'changed'].
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    69
        t := Toggle new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    70
        t model:m.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    71
        t label:'toggle me'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    72
        t open.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    73
                                                                        [exEnd]
75
claus
parents:
diff changeset
    74
claus
parents:
diff changeset
    75
76
claus
parents: 75
diff changeset
    76
    an adaptor to send #destroy:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    77
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    78
        |m t|
75
claus
parents:
diff changeset
    79
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    80
        m := (PluggableAdaptor new)
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    81
                getBlock:[:m | false]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    82
                putBlock:[:m :newValue | t destroy]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    83
                updateBlock:[:m :aspect :param | ].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    84
        t := Button new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    85
        t model:m.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    86
        t label:'close me'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    87
        t open.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    88
                                                                        [exEnd]
75
claus
parents:
diff changeset
    89
claus
parents:
diff changeset
    90
claus
parents:
diff changeset
    91
    as above, more convenient setup:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    92
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    93
        |m t|
75
claus
parents:
diff changeset
    94
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    95
        t := Button new.
75
claus
parents:
diff changeset
    96
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    97
        m := (PluggableAdaptor on:t) performAction:#destroy.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    98
        t model:m.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
    99
        t label:'close me'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   100
        t open.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   101
                                                                        [exEnd]
75
claus
parents:
diff changeset
   102
claus
parents:
diff changeset
   103
    extract values from a complex model:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   104
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   105
        |model dialog  name pId|
75
claus
parents:
diff changeset
   106
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   107
        model := Plug new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   108
        model respondTo:#name with:[name].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   109
        model respondTo:#name: with:[:newValue | name := newValue].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   110
        model respondTo:#passportId with:[pId].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   111
        model respondTo:#passportId: with:[:newValue | pId := newValue].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   112
        name := 'John Smith'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   113
        pId := 56785432.
75
claus
parents:
diff changeset
   114
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   115
        dialog := Dialog new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   116
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   117
        dialog addInputFieldOn:((PluggableAdaptor on:model)
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   118
                                    getBlock:[:m | m name]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   119
                                    putBlock:[:m :v | m name:v]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   120
                                    updateBlock:[:m :a :p | false]).
75
claus
parents:
diff changeset
   121
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   122
        dialog addVerticalSpace.
75
claus
parents:
diff changeset
   123
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   124
        dialog addInputFieldOn:((PluggableAdaptor on:model)
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   125
                                    getBlock:[:m | m passportId printString]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   126
                                    putBlock:[:m :v | m passportId:v asNumber]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   127
                                    updateBlock:[:m :a :p | false]).
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   128
        dialog addAbortButton; addOkButton.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   129
        dialog width:200; sizeFixed:true.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   130
        dialog open.
75
claus
parents:
diff changeset
   131
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   132
        dialog accept value ifTrue:[
268
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
   133
            Transcript showCR:'accepted.'.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   134
        ].
268
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
   135
        Transcript showCR:'  Name: ' , model name.
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
   136
        Transcript showCR:'  ID  : ' , model passportId printString.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   137
                                                                        [exEnd]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   138
75
claus
parents:
diff changeset
   139
claus
parents:
diff changeset
   140
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   141
    extract values from an association into different labels:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   142
                                                                        [exBegin]
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   143
        |assoc t l|
82
claus
parents: 79
diff changeset
   144
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   145
        assoc := 'hello' -> 'world'.
82
claus
parents: 79
diff changeset
   146
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   147
        t := HorizontalPanelView new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   148
        t extent:200@50.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   149
        t horizontalLayout:#fitSpace.
82
claus
parents: 79
diff changeset
   150
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   151
        l := Label in:t.
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   152
        l model:((PluggableAdaptor on:assoc) getSelector:#key putSelector:#key:);
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   153
          labelMessage:#value; aspect:#value;
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   154
          level:-1.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   155
        l := Label in:t.
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   156
        l model:((PluggableAdaptor on:assoc) getSelector:#value putSelector:#value:);
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   157
          labelMessage:#value; aspect:#value;
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   158
          level:-1.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   159
        t open.
82
claus
parents: 79
diff changeset
   160
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   161
        (Delay forSeconds:3) wait.
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   162
        assoc key:'goodbye'.
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   163
        assoc changed.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   164
                                                                        [exEnd]
82
claus
parents: 79
diff changeset
   165
claus
parents: 79
diff changeset
   166
    extract values from an array into different labels:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   167
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   168
        |a t l|
75
claus
parents:
diff changeset
   169
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   170
        a := #('one' 'two' 'three').
75
claus
parents:
diff changeset
   171
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   172
        t := HorizontalPanelView new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   173
        t extent:200@50.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   174
        t horizontalLayout:#fitSpace.
75
claus
parents:
diff changeset
   175
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   176
        l := Label in:t.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   177
        l model:((PluggableAdaptor on:a) collectionIndex:1);
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   178
          labelMessage:#value; aspect:#value;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   179
          level:-1;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   180
          sizeFixed:true.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   181
        l := Label in:t.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   182
        l model:((PluggableAdaptor on:a) collectionIndex:2);
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   183
          labelMessage:#value; aspect:#value;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   184
          level:-1;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   185
          sizeFixed:true.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   186
        l := Label in:t.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   187
        l model:((PluggableAdaptor on:a) collectionIndex:3);
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   188
          labelMessage:#value; aspect:#value;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   189
          level:-1;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   190
          sizeFixed:true.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   191
        t open.
75
claus
parents:
diff changeset
   192
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   193
        (Delay forSeconds:3) wait.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   194
        a at:1 put:'1'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   195
        a changed.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   196
                                                                        [exEnd]
75
claus
parents:
diff changeset
   197
"
claus
parents:
diff changeset
   198
! !
claus
parents:
diff changeset
   199
claus
parents:
diff changeset
   200
!PluggableAdaptor class methodsFor:'instance creation'!
claus
parents:
diff changeset
   201
claus
parents:
diff changeset
   202
on:anObject
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   203
    "create & return a new protocolAdaptor.
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   204
     Any get/put and updateBlocks are still to be defined"
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   205
75
claus
parents:
diff changeset
   206
    ^ self new model:anObject
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   207
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   208
    "Modified: 21.2.1997 / 18:31:22 / cg"
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   209
!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   210
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   211
on:anObject getter:getterBlock
2881
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   212
    ^ (self on:anObject) getter:getterBlock
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   213
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   214
    "Created: / 08-08-2004 / 21:54:04 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   215
    "Modified: / 20-04-2005 / 18:59:28 / janfrog"
2881
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   216
    "Modified: / 22-12-2010 / 11:29:14 / cg"
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   217
!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   218
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   219
on:anObject getter:getterBlock setter:setterBlock
2881
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   220
    ^ (self on:anObject) getter:getterBlock setter:setterBlock
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   221
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   222
    "Created: / 08-08-2004 / 21:53:58 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   223
    "Modified: / 20-04-2005 / 18:59:28 / janfrog"
2881
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   224
    "Modified: / 22-12-2010 / 11:29:18 / cg"
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   225
!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   226
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   227
on:anObject setter:setterBlock
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   228
    ^ (self on:anObject)
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   229
        setter:setterBlock
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   230
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   231
    "Created: / 08-08-2004 / 21:54:12 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   232
    "Modified: / 20-04-2005 / 18:59:28 / janfrog"
75
claus
parents:
diff changeset
   233
! !
claus
parents:
diff changeset
   234
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   235
!PluggableAdaptor methodsFor:'accessing'!
75
claus
parents:
diff changeset
   236
2622
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   237
getBlock
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   238
    ^ getBlock
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   239
!
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   240
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   241
putBlock
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   242
    ^ putBlock
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   243
!
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   244
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   245
setValue:newValue
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   246
    putBlock notNil ifTrue:[
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   247
	^ putBlock value:model value:newValue
75
claus
parents:
diff changeset
   248
    ].
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   249
    model value:newValue "/ stupid default
75
claus
parents:
diff changeset
   250
!
claus
parents:
diff changeset
   251
2622
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   252
updateBlock
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   253
    ^ updateBlock
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   254
!
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   255
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   256
value
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   257
    getBlock notNil ifTrue:[
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   258
	^ getBlock value:model
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   259
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   260
    ^ model value "/ stupid default
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   261
!
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   262
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   263
valueUsingSubject:someObject
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   264
    someObject isNil ifTrue:[^ nil].
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   265
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   266
    ^ getBlock value:someObject
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   267
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   268
    "Created: 21.2.1997 / 18:28:35 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   269
! !
75
claus
parents:
diff changeset
   270
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1127
diff changeset
   271
!PluggableAdaptor methodsFor:'change & update'!
75
claus
parents:
diff changeset
   272
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   273
update:something with:aParameter from:changedObject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   274
    changedObject == model ifTrue:[
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   275
        updateBlock notNil ifTrue:[
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   276
            (updateBlock value:model value:something value:aParameter)
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   277
            ifTrue:[
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   278
                self changed:#value
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   279
            ]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   280
        ]
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   281
    ].
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   282
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   283
    "Modified: 21.2.1997 / 18:28:52 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   284
! !
75
claus
parents:
diff changeset
   285
1769
c6db6b7bd59a method category rename
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
   286
!PluggableAdaptor methodsFor:'initialization & release'!
75
claus
parents:
diff changeset
   287
claus
parents:
diff changeset
   288
collectionIndex:idx
claus
parents:
diff changeset
   289
    "configure the adaptor to translate #value/#value:-messages into
claus
parents:
diff changeset
   290
     indexed accesses via #at:/#at:put:, using the supplied index"
claus
parents:
diff changeset
   291
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   292
    getBlock := [:model | model value at:idx].
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   293
    putBlock := [:model :newValue | model value at:idx put:newValue].
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   294
    updateBlock := [:model :aspect :parameter |
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   295
                        aspect isNil or:[aspect == #value]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   296
                   ]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   297
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   298
    "Modified: 21.2.1997 / 18:20:24 / cg"
75
claus
parents:
diff changeset
   299
!
claus
parents:
diff changeset
   300
2619
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   301
getBlock:newGetBlock
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   302
    "configure the adaptor to translate #value-messages into
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   303
     evaluation of the corresponding block.
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   304
     The getBlock argument block1 is called with one argument, the model, and is
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   305
     supposed to extract & return a value from that model."
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   306
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   307
    getBlock := newGetBlock.
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   308
!
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   309
2119
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   310
getBlock:newGetBlock putBlock:newPutBlock
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   311
    "configure the adaptor to translate #value/#value:-messages into
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   312
     evaluation of the corresponding block1/block2.
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   313
     The getBlock argument block1 is called with one argument, the model, and is
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   314
     supposed to extract & return a value from that model.
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   315
     The putBlock argument, block2 is called with 2 arguments, the model
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   316
     and the new value, and is supposed to store the new value."
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   317
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   318
    getBlock := newGetBlock.
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   319
    putBlock := newPutBlock.
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   320
!
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   321
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   322
getBlock:newGetBlock putBlock:newPutBlock updateBlock:newUpdateBlock
75
claus
parents:
diff changeset
   323
    "configure the adaptor to translate #value/#value:-messages into
claus
parents:
diff changeset
   324
     evaluation of the corresponding block1/block2.
claus
parents:
diff changeset
   325
     The getBlock argument block1 is called with one argument, the model, and is
claus
parents:
diff changeset
   326
     supposed to extract & return a value from that model.
claus
parents:
diff changeset
   327
     The putBlock argument, block2 is called with 2 arguments, the model
claus
parents:
diff changeset
   328
     and the new value, and is supposed to store the new value.
claus
parents:
diff changeset
   329
     The updateBlock argument, block3 is called with 3 arguments, the model,
claus
parents:
diff changeset
   330
     the aspect as changed in the model and the change parameter. It
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   331
     is called when the adaptor receives an update message from the model,
75
claus
parents:
diff changeset
   332
     and should return true if a new value should be fetched from the model."
claus
parents:
diff changeset
   333
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   334
    getBlock := newGetBlock.
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   335
    putBlock := newPutBlock.
2383
Claus Gittinger <cg@exept.de>
parents: 2378
diff changeset
   336
    self assert:(newUpdateBlock isNil or:[newUpdateBlock numArgs == 3]).
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   337
    updateBlock := newUpdateBlock.
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   338
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   339
    "Modified: 21.2.1997 / 18:18:38 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   340
!
75
claus
parents:
diff changeset
   341
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   342
getSelector:getSelector putSelector:putSelector
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   343
    "configure the adaptor to translate #value-messages into a send of
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   344
     getSelector and #value:-messages into sends of putSelector."
75
claus
parents:
diff changeset
   345
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   346
    getBlock := [:model | model perform:getSelector].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   347
    putBlock := [:model :newValue | model perform:putSelector with:newValue].
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   348
    updateBlock := [:model :aspect :parameter |
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   349
                        aspect isNil
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   350
                        or:[aspect == getSelector
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   351
                        or:[aspect == #value]]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   352
                   ]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   353
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   354
    "Modified: 21.2.1997 / 18:21:27 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   355
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   356
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   357
model:anObject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   358
    model notNil ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   359
       model removeDependent:self
75
claus
parents:
diff changeset
   360
    ].
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   361
    model := anObject.
1127
4565ab2ad23c dont get confused with a nil model.
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   362
    model notNil ifTrue:[
4565ab2ad23c dont get confused with a nil model.
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   363
        model addDependent:self
4565ab2ad23c dont get confused with a nil model.
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   364
    ]
75
claus
parents:
diff changeset
   365
!
claus
parents:
diff changeset
   366
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   367
performAction:aSelector
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   368
    "configure the adaptor to send an aSelector-message to the model
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   369
     whenever a new value is stored via #value:"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   370
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   371
    getBlock := [:model | nil].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   372
    putBlock := [:model :newValue | model perform:aSelector].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   373
    updateBlock := [:model :aspect :parameter | false]
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   374
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   375
2619
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   376
putBlock:newPutBlock
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   377
    "configure the adaptor to translate#value:-messages into
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   378
     evaluation of the corresponding block2.
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   379
     The putBlock argument, block2 is called with 2 arguments, the model
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   380
     and the new value, and is supposed to store the new value."
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   381
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   382
    putBlock := newPutBlock.
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   383
!
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   384
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   385
selectValue:something
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   386
    "configure the adaptor to behave like a boolean value, returning
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   387
     true whenever the models value equals something"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   388
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   389
"/    getBlock := [:model | model value = something].
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   390
"/    putBlock := [:model :newValue | newValue ifTrue:[model value:something]].
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   391
"/    updateBlock := [:model :aspect :parameter |
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   392
"/                        aspect isNil or:[aspect == #value]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   393
"/                   ]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   394
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   395
    "/ changed for vw compatibility
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   396
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   397
    |lastValue|
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   398
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   399
    lastValue := nil.
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   400
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   401
    getBlock := [:model | lastValue := (model value = something)].
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   402
    putBlock := [:model :newValue | newValue
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   403
                                        ifTrue:[model value:something]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   404
                                        ifFalse:[model value = something
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   405
                                                     ifTrue:[model value:nil]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   406
                                        ]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   407
                ].
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   408
    updateBlock := [:model :aspect :parameter |
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   409
                        ((model value = something) = lastValue) not
352
ba7970fbcde2 Fix #selectValue: (Used by T-gen).
Stefan Vogel <sv@exept.de>
parents: 268
diff changeset
   410
                   ]
ba7970fbcde2 Fix #selectValue: (Used by T-gen).
Stefan Vogel <sv@exept.de>
parents: 268
diff changeset
   411
ba7970fbcde2 Fix #selectValue: (Used by T-gen).
Stefan Vogel <sv@exept.de>
parents: 268
diff changeset
   412
    "Modified: 31.12.1996 / 13:58:09 / stefan"
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   413
    "Modified: 21.2.1997 / 18:27:26 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   414
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   415
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   416
subjectChannel:aValueHolder
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   417
    "setup to use aValueHolder as model"
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   418
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   419
    self model:aValueHolder
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   420
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   421
    "Modified: 21.2.1997 / 18:19:46 / cg"
75
claus
parents:
diff changeset
   422
! !
claus
parents:
diff changeset
   423
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   424
!PluggableAdaptor methodsFor:'utilities'!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   425
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   426
getter:getterBlock
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   427
    self
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   428
        getter:getterBlock
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   429
        setter:[:value|self shouldNeverBeReached]
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   430
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   431
    "Created: / 08-08-2004 / 21:53:02 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   432
    "Modified: / 20-04-2005 / 18:59:28 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   433
!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   434
3310
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   435
getter:getter setter:setter
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   436
    | getterBlock setterBlock |
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   437
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   438
    getterBlock := getter.
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   439
    setter numArgs == 1 ifTrue:[
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   440
    	setterBlock := [:model :value| model value:(setter  value:value)]
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   441
    ] ifFalse:[
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   442
        setterBlock := setter
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   443
    ].
3310
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   444
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   445
    self
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   446
        getBlock:getterBlock
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   447
        putBlock:setterBlock
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   448
        updateBlock:[:model :aspect :value|true]
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   449
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   450
    "Created: / 08-08-2004 / 21:52:20 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   451
    "Modified: / 20-04-2005 / 18:59:28 / janfrog"
3310
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   452
    "Modified: / 14-03-2014 / 23:21:25 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   453
!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   454
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   455
setter:setterBlock
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   456
    self
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   457
        getter:[:value|self shouldNeverBeReached]
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   458
        setter:setterBlock
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   459
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   460
    "Created: / 08-08-2004 / 21:53:19 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   461
    "Modified: / 20-04-2005 / 18:59:28 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   462
! !
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   463
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   464
!PluggableAdaptor class methodsFor:'documentation'!
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   465
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   466
version
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   467
    ^ '$Header: /cvs/stx/stx/libview2/PluggableAdaptor.st,v 1.26 2014-03-15 13:58:13 vrany Exp $'
2881
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   468
!
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   469
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   470
version_CVS
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   471
    ^ '$Header: /cvs/stx/stx/libview2/PluggableAdaptor.st,v 1.26 2014-03-15 13:58:13 vrany Exp $'
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   472
! !
3310
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   473