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