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