PluggableAdaptor.st
author Claus Gittinger <cg@exept.de>
Thu, 23 Jan 2020 17:47:56 +0100
changeset 4431 732c2cd831b8
parent 4339 f98b7fa24c7a
permissions -rw-r--r--
#OTHER by cg fix: if moving over an item within the same view, possibly suppress already forked and scheduled helptext (eg. when moving over close-icon in a tabList, moving within the same tab label, but away from the close icon, the tooltip was shown erronously in the previous version)
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
4327
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   107
    choose one from alternatives (radioButton-like behavior):
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   108
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   109
                                                                        [exBegin]
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   110
        |m v|
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   111
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   112
        m := #foo asValue.
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   113
        v := HorizontalPanelView new.
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   114
        v add:(Toggle on:((PluggableAdaptor on:m) selectValue:#foo) label:'foo' ).
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   115
        v add:(Toggle on:((PluggableAdaptor on:m) selectValue:#bar) label:'bar' ).
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   116
        v add:(Toggle on:((PluggableAdaptor on:m) selectValue:#baz) label:'baz' ).
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   117
        v add:(Label label:'Current:' ).
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   118
        v add:(Label new labelChannel:m ).
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   119
        v open.
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   120
                                                                        [exEnd]
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   121
75
claus
parents:
diff changeset
   122
    extract values from a complex model:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   123
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   124
        |model dialog  name pId|
75
claus
parents:
diff changeset
   125
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   126
        model := Plug new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   127
        model respondTo:#name with:[name].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   128
        model respondTo:#name: with:[:newValue | name := newValue].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   129
        model respondTo:#passportId with:[pId].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   130
        model respondTo:#passportId: with:[:newValue | pId := newValue].
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   131
        name := 'John Smith'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   132
        pId := 56785432.
75
claus
parents:
diff changeset
   133
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   134
        dialog := Dialog new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   135
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   136
        dialog addInputFieldOn:((PluggableAdaptor on:model)
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   137
                                    getBlock:[:m | m name]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   138
                                    putBlock:[:m :v | m name:v]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   139
                                    updateBlock:[:m :a :p | false]).
75
claus
parents:
diff changeset
   140
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   141
        dialog addVerticalSpace.
75
claus
parents:
diff changeset
   142
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   143
        dialog addInputFieldOn:((PluggableAdaptor on:model)
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   144
                                    getBlock:[:m | m passportId printString]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   145
                                    putBlock:[:m :v | m passportId:v asNumber]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   146
                                    updateBlock:[:m :a :p | false]).
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   147
        dialog addAbortButton; addOkButton.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   148
        dialog width:200; sizeFixed:true.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   149
        dialog open.
75
claus
parents:
diff changeset
   150
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   151
        dialog accept value ifTrue:[
268
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
   152
            Transcript showCR:'accepted.'.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   153
        ].
268
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
   154
        Transcript showCR:'  Name: ' , model name.
1998023f12dc showCr: -> showCR:
Claus Gittinger <cg@exept.de>
parents: 231
diff changeset
   155
        Transcript showCR:'  ID  : ' , model passportId printString.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   156
                                                                        [exEnd]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   157
75
claus
parents:
diff changeset
   158
claus
parents:
diff changeset
   159
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   160
    extract values from an association into different labels:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   161
                                                                        [exBegin]
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   162
        |assoc t l|
82
claus
parents: 79
diff changeset
   163
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   164
        assoc := 'hello' -> 'world'.
82
claus
parents: 79
diff changeset
   165
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   166
        t := HorizontalPanelView new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   167
        t extent:200@50.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   168
        t horizontalLayout:#fitSpace.
82
claus
parents: 79
diff changeset
   169
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   170
        l := Label in:t.
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   171
        l model:((PluggableAdaptor on:assoc) getSelector:#key putSelector:#key:);
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   172
          labelMessage:#value; aspect:#value;
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   173
          level:-1.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   174
        l := Label in:t.
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   175
        l model:((PluggableAdaptor on:assoc) getSelector:#value putSelector:#value:);
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   176
          labelMessage:#value; aspect:#value;
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   177
          level:-1.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   178
        t open.
82
claus
parents: 79
diff changeset
   179
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   180
        (Delay forSeconds:3) wait.
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   181
        assoc key:'goodbye'.
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   182
        assoc changed.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   183
                                                                        [exEnd]
82
claus
parents: 79
diff changeset
   184
claus
parents: 79
diff changeset
   185
    extract values from an array into different labels:
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   186
                                                                        [exBegin]
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   187
        |a t l|
75
claus
parents:
diff changeset
   188
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   189
        a := #('one' 'two' 'three').
75
claus
parents:
diff changeset
   190
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   191
        t := HorizontalPanelView new.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   192
        t extent:200@50.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   193
        t horizontalLayout:#fitSpace.
75
claus
parents:
diff changeset
   194
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   195
        l := Label in:t.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   196
        l model:((PluggableAdaptor on:a) collectionIndex:1);
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   197
          labelMessage:#value; aspect:#value;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   198
          level:-1;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   199
          sizeFixed:true.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   200
        l := Label in:t.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   201
        l model:((PluggableAdaptor on:a) collectionIndex:2);
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   202
          labelMessage:#value; aspect:#value;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   203
          level:-1;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   204
          sizeFixed:true.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   205
        l := Label in:t.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   206
        l model:((PluggableAdaptor on:a) collectionIndex:3);
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   207
          labelMessage:#value; aspect:#value;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   208
          level:-1;
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   209
          sizeFixed:true.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   210
        t open.
75
claus
parents:
diff changeset
   211
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   212
        (Delay forSeconds:3) wait.
231
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   213
        a at:1 put:'1'.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   214
        a changed.
2fec6188bd28 examples
Claus Gittinger <cg@exept.de>
parents: 223
diff changeset
   215
                                                                        [exEnd]
75
claus
parents:
diff changeset
   216
"
claus
parents:
diff changeset
   217
! !
claus
parents:
diff changeset
   218
claus
parents:
diff changeset
   219
!PluggableAdaptor class methodsFor:'instance creation'!
claus
parents:
diff changeset
   220
claus
parents:
diff changeset
   221
on:anObject
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   222
    "create & return a new protocolAdaptor.
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   223
     Any get/put and updateBlocks are still to be defined"
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   224
75
claus
parents:
diff changeset
   225
    ^ self new model:anObject
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   226
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   227
    "Modified: 21.2.1997 / 18:31:22 / cg"
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   228
!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   229
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   230
on:anObject getter:getterBlock
2881
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   231
    ^ (self on:anObject) getter:getterBlock
2743
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:04 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   234
    "Modified: / 20-04-2005 / 18:59:28 / janfrog"
2881
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   235
    "Modified: / 22-12-2010 / 11:29:14 / cg"
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   236
!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   237
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   238
on:anObject getter:getterBlock setter:setterBlock
2881
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   239
    ^ (self on:anObject) getter:getterBlock setter:setterBlock
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   240
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   241
    "Created: / 08-08-2004 / 21:53:58 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   242
    "Modified: / 20-04-2005 / 18:59:28 / janfrog"
2881
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   243
    "Modified: / 22-12-2010 / 11:29:18 / cg"
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   244
!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   245
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   246
on:anObject setter:setterBlock
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   247
    ^ (self on:anObject)
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   248
        setter:setterBlock
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   249
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   250
    "Created: / 08-08-2004 / 21:54:12 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   251
    "Modified: / 20-04-2005 / 18:59:28 / janfrog"
75
claus
parents:
diff changeset
   252
! !
claus
parents:
diff changeset
   253
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   254
!PluggableAdaptor methodsFor:'accessing'!
75
claus
parents:
diff changeset
   255
2622
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   256
getBlock
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   257
    ^ getBlock
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
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   260
putBlock
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   261
    ^ putBlock
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   262
!
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   263
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   264
setValue:newValue
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   265
    putBlock notNil ifTrue:[
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   266
	^ putBlock value:model value:newValue
75
claus
parents:
diff changeset
   267
    ].
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   268
    model value:newValue "/ stupid default
75
claus
parents:
diff changeset
   269
!
claus
parents:
diff changeset
   270
2622
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   271
updateBlock
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   272
    ^ updateBlock
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   273
!
aae1c83162bc access methods
Stefan Vogel <sv@exept.de>
parents: 2619
diff changeset
   274
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   275
value
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   276
    getBlock notNil ifTrue:[
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   277
	^ getBlock value:model
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   278
    ].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   279
    ^ model value "/ stupid default
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   280
!
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
valueUsingSubject:someObject
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   283
    someObject isNil ifTrue:[^ nil].
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
    ^ getBlock value:someObject
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
    "Created: 21.2.1997 / 18:28:35 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   288
! !
75
claus
parents:
diff changeset
   289
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1127
diff changeset
   290
!PluggableAdaptor methodsFor:'change & update'!
75
claus
parents:
diff changeset
   291
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   292
update:something with:aParameter from:changedObject
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   293
    changedObject == model ifTrue:[
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   294
        updateBlock notNil ifTrue:[
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   295
            (updateBlock value:model value:something value:aParameter)
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   296
            ifTrue:[
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   297
                self changed:#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
        ]
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   300
    ].
443
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:28:52 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   303
! !
75
claus
parents:
diff changeset
   304
1769
c6db6b7bd59a method category rename
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
   305
!PluggableAdaptor methodsFor:'initialization & release'!
75
claus
parents:
diff changeset
   306
claus
parents:
diff changeset
   307
collectionIndex:idx
claus
parents:
diff changeset
   308
    "configure the adaptor to translate #value/#value:-messages into
claus
parents:
diff changeset
   309
     indexed accesses via #at:/#at:put:, using the supplied index"
claus
parents:
diff changeset
   310
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   311
    getBlock := [:model | model value at:idx].
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   312
    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
   313
    updateBlock := [:model :aspect :parameter |
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   314
                        aspect isNil or:[aspect == #value]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   315
                   ]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   316
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   317
    "Modified: 21.2.1997 / 18:20:24 / cg"
75
claus
parents:
diff changeset
   318
!
claus
parents:
diff changeset
   319
2619
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   320
getBlock:newGetBlock
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   321
    "configure the adaptor to translate #value-messages into
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   322
     evaluation of the corresponding block.
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   323
     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
   324
     supposed to extract & return a value from that model."
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   325
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   326
    getBlock := newGetBlock.
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   327
!
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   328
2119
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   329
getBlock:newGetBlock putBlock:newPutBlock
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   330
    "configure the adaptor to translate #value/#value:-messages into
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   331
     evaluation of the corresponding block1/block2.
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   332
     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
   333
     supposed to extract & return a value from that model.
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   334
     The putBlock argument, block2 is called with 2 arguments, the model
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   335
     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
   336
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   337
    getBlock := newGetBlock.
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   338
    putBlock := newPutBlock.
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   339
!
c7f9c288469c *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1769
diff changeset
   340
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   341
getBlock:newGetBlock putBlock:newPutBlock updateBlock:newUpdateBlock
75
claus
parents:
diff changeset
   342
    "configure the adaptor to translate #value/#value:-messages into
claus
parents:
diff changeset
   343
     evaluation of the corresponding block1/block2.
claus
parents:
diff changeset
   344
     The getBlock argument block1 is called with one argument, the model, and is
claus
parents:
diff changeset
   345
     supposed to extract & return a value from that model.
claus
parents:
diff changeset
   346
     The putBlock argument, block2 is called with 2 arguments, the model
claus
parents:
diff changeset
   347
     and the new value, and is supposed to store the new value.
claus
parents:
diff changeset
   348
     The updateBlock argument, block3 is called with 3 arguments, the model,
claus
parents:
diff changeset
   349
     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
   350
     is called when the adaptor receives an update message from the model,
75
claus
parents:
diff changeset
   351
     and should return true if a new value should be fetched from the model."
claus
parents:
diff changeset
   352
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   353
    getBlock := newGetBlock.
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   354
    putBlock := newPutBlock.
4339
f98b7fa24c7a #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 4327
diff changeset
   355
    self assert:(newUpdateBlock isNil or:[newUpdateBlock argumentCount == 3]).
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   356
    updateBlock := newUpdateBlock.
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:18:38 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   359
!
75
claus
parents:
diff changeset
   360
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   361
getSelector:getSelector putSelector:putSelector
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   362
    "configure the adaptor to translate #value-messages into a send of
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   363
     getSelector and #value:-messages into sends of putSelector."
75
claus
parents:
diff changeset
   364
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   365
    getBlock := [:model | model perform:getSelector].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   366
    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
   367
    updateBlock := [:model :aspect :parameter |
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   368
                        aspect isNil
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   369
                        or:[aspect == getSelector
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   370
                        or:[aspect == #value]]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   371
                   ]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   372
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   373
    "Modified: 21.2.1997 / 18:21:27 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   374
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   375
3735
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   376
model
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   377
    "get the real model, into which / from which the
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   378
     real model value is converted"
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   379
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   380
    ^ model 
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   381
!
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   382
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   383
model:anObject
3735
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   384
    "set the real model, into which / from which the
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   385
     real model value is converted"
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   386
     
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   387
    model notNil ifTrue:[
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   388
       model removeDependent:self
75
claus
parents:
diff changeset
   389
    ].
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   390
    model := anObject.
1127
4565ab2ad23c dont get confused with a nil model.
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   391
    model notNil ifTrue:[
4565ab2ad23c dont get confused with a nil model.
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   392
        model addDependent:self
4565ab2ad23c dont get confused with a nil model.
Claus Gittinger <cg@exept.de>
parents: 443
diff changeset
   393
    ]
75
claus
parents:
diff changeset
   394
!
claus
parents:
diff changeset
   395
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   396
performAction:aSelector
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   397
    "configure the adaptor to send an aSelector-message to the model
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   398
     whenever a new value is stored via #value:"
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   399
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   400
    getBlock := [:model | nil].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   401
    putBlock := [:model :newValue | model perform:aSelector].
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   402
    updateBlock := [:model :aspect :parameter | false]
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   403
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   404
2619
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   405
putBlock:newPutBlock
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   406
    "configure the adaptor to translate#value:-messages into
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   407
     evaluation of the corresponding block2.
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   408
     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
   409
     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
   410
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   411
    putBlock := newPutBlock.
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   412
!
4b16e812918f new: #getBlock: and #putBlock:
Stefan Vogel <sv@exept.de>
parents: 2383
diff changeset
   413
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   414
selectValue:something
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   415
    "configure the adaptor to behave like a boolean value, returning
4327
2564d42c6024 #FEATURE by exept
Claus Gittinger <cg@exept.de>
parents: 3735
diff changeset
   416
     true whenever the model's value equals something"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   417
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   418
"/    getBlock := [:model | model value = something].
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   419
"/    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
   420
"/    updateBlock := [:model :aspect :parameter |
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   421
"/                        aspect isNil or:[aspect == #value]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   422
"/                   ]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   423
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   424
    "/ changed for vw compatibility
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   425
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   426
    |lastValue|
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   427
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   428
    lastValue := nil.
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   429
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   430
    getBlock := [:model | lastValue := (model value = something)].
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   431
    putBlock := [:model :newValue | newValue
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   432
                                        ifTrue:[model value:something]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   433
                                        ifFalse:[model value = something
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   434
                                                     ifTrue:[model value:nil]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   435
                                        ]
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   436
                ].
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   437
    updateBlock := [:model :aspect :parameter |
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   438
                        ((model value = something) = lastValue) not
352
ba7970fbcde2 Fix #selectValue: (Used by T-gen).
Stefan Vogel <sv@exept.de>
parents: 268
diff changeset
   439
                   ]
ba7970fbcde2 Fix #selectValue: (Used by T-gen).
Stefan Vogel <sv@exept.de>
parents: 268
diff changeset
   440
ba7970fbcde2 Fix #selectValue: (Used by T-gen).
Stefan Vogel <sv@exept.de>
parents: 268
diff changeset
   441
    "Modified: 31.12.1996 / 13:58:09 / stefan"
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   442
    "Modified: 21.2.1997 / 18:27:26 / cg"
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   443
!
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   444
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   445
subjectChannel:aValueHolder
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   446
    "setup to use aValueHolder as model"
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   447
125
fa5b5e4336bf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   448
    self model:aValueHolder
443
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   449
5c57a8861677 st-80 compatible selectValue:
Claus Gittinger <cg@exept.de>
parents: 352
diff changeset
   450
    "Modified: 21.2.1997 / 18:19:46 / cg"
75
claus
parents:
diff changeset
   451
! !
claus
parents:
diff changeset
   452
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   453
!PluggableAdaptor methodsFor:'utilities'!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   454
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   455
getter:getterBlock
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   456
    self
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   457
        getter:getterBlock
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   458
        setter:[:value|self shouldNeverBeReached]
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   459
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   460
    "Created: / 08-08-2004 / 21:53:02 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   461
    "Modified: / 20-04-2005 / 18:59:28 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   462
!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   463
3310
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   464
getter:getter setter:setter
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   465
    | getterBlock setterBlock |
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   466
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   467
    getterBlock := getter.
4339
f98b7fa24c7a #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 4327
diff changeset
   468
    setter argumentCount == 1 ifTrue:[
f98b7fa24c7a #REFACTORING by exept
Claus Gittinger <cg@exept.de>
parents: 4327
diff changeset
   469
        setterBlock := [:model :value| model value:(setter  value:value)]
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   470
    ] ifFalse:[
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   471
        setterBlock := setter
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   472
    ].
3310
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   473
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   474
    self
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   475
        getBlock:getterBlock
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   476
        putBlock:setterBlock
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   477
        updateBlock:[:model :aspect :value|true]
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   478
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   479
    "Created: / 08-08-2004 / 21:52:20 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   480
    "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
   481
    "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
   482
!
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   483
3311
514c65e7f366 Workaround for stc bug, sigh.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 3310
diff changeset
   484
setter:setterBlock
2743
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   485
    self
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   486
        getter:[:value|self shouldNeverBeReached]
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   487
        setter:setterBlock
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   488
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   489
    "Created: / 08-08-2004 / 21:53:19 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   490
    "Modified: / 20-04-2005 / 18:59:28 / janfrog"
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   491
! !
e4b1622a4d1a *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2622
diff changeset
   492
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   493
!PluggableAdaptor class methodsFor:'documentation'!
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   494
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   495
version
3735
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   496
    ^ '$Header$'
2881
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   497
!
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   498
1195db0166d3 comment/format in:
Claus Gittinger <cg@exept.de>
parents: 2743
diff changeset
   499
version_CVS
3735
e779b06d9ac9 #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 3440
diff changeset
   500
    ^ '$Header$'
129
f890eaabc487 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 125
diff changeset
   501
! !
3310
b0eef4f85fc9 Be more tolerant in PluggableAdaptor>>#getter:setter:
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 2881
diff changeset
   502