Tools__ViewTreeApplication.st
changeset 3398 9c87da351c9c
parent 3383 9041e2616a95
child 3453 01e6b207c1b4
     1.1 --- a/Tools__ViewTreeApplication.st	Wed Feb 08 01:02:22 2017 +0100
     1.2 +++ b/Tools__ViewTreeApplication.st	Sun Feb 12 11:54:51 2017 +0100
     1.3 @@ -4071,42 +4071,52 @@
     1.4  do:aOneArgBlock
     1.5      "evaluate the argument, aBlock for each item in the selection
     1.6      "
     1.7 -    |cashedSelection|
     1.8 -
     1.9 -    cashedSelection := selection.
    1.10 -    cashedSelection isNil ifTrue:[^ nil].
    1.11 -  ^ cashedSelection do:aOneArgBlock
    1.12 +    |keptSelection|
    1.13 +
    1.14 +    "/ the selection may change at any time (may it?)
    1.15 +    (keptSelection := selection) isNil ifTrue:[^ nil].
    1.16 +    ^ keptSelection do:aOneArgBlock
    1.17 +
    1.18 +    "Modified (format): / 12-02-2017 / 11:53:23 / cg"
    1.19  !
    1.20  
    1.21  from:start do:aOneArgBlock
    1.22      "evaluate the argument, aBlock for the items starting at index start
    1.23      "
    1.24 -    |cashedSelection|
    1.25 -
    1.26 -    cashedSelection := selection.
    1.27 -    cashedSelection isNil ifTrue:[^ nil].
    1.28 -  ^ cashedSelection from:start do:aOneArgBlock
    1.29 +    |keptSelection|
    1.30 +
    1.31 +    "/ the selection may change at any time (may it?)
    1.32 +    (keptSelection := selection) isNil ifTrue:[^ nil].
    1.33 +    "/ but if so, then start may no longer be valid here??
    1.34 +    ^ keptSelection from:start do:aOneArgBlock
    1.35 +
    1.36 +    "Modified (comment): / 12-02-2017 / 11:52:57 / cg"
    1.37  !
    1.38  
    1.39  from:start to:stop do:aOneArgBlock
    1.40      "evaluate the argument, aBlock for the items with index start to
    1.41       stop in the selection.
    1.42      "
    1.43 -    |cashedSelection|
    1.44 -
    1.45 -    cashedSelection := selection.
    1.46 -    cashedSelection isNil ifTrue:[^ nil].
    1.47 -  ^ cashedSelection from:start to:stop do:aOneArgBlock
    1.48 +    |keptSelection|
    1.49 +
    1.50 +    "/ the selection may change at any time (may it?)
    1.51 +    (keptSelection := selection) isNil ifTrue:[^ nil].
    1.52 +    "/ but if so, then start and stop may no longer be valid here??
    1.53 +    ^ keptSelection from:start to:stop do:aOneArgBlock
    1.54 +
    1.55 +    "Modified (comment): / 12-02-2017 / 11:52:25 / cg"
    1.56  !
    1.57  
    1.58  reverseDo:aOneArgBlock
    1.59      "evaluate the argument, aBlock for each item in the selection
    1.60      "
    1.61 -    |cashedSelection|
    1.62 -
    1.63 -    cashedSelection := selection.
    1.64 -    cashedSelection isNil ifTrue:[^ nil].
    1.65 -  ^ cashedSelection reverseDo:aOneArgBlock
    1.66 +    |keptSelection|
    1.67 +
    1.68 +    "/ the selection may change at any time (may it?)
    1.69 +    (keptSelection := selection) isNil ifTrue:[^ nil].
    1.70 +    ^ keptSelection reverseDo:aOneArgBlock
    1.71 +
    1.72 +    "Modified: / 12-02-2017 / 11:50:02 / cg"
    1.73  !
    1.74  
    1.75  select:aBlock
    1.76 @@ -4259,11 +4269,13 @@
    1.77       If none of the evaluations returns true, the result of the evaluation
    1.78       of the exceptionBlock is returned
    1.79      "
    1.80 -    |cashedSelection|
    1.81 -
    1.82 -    cashedSelection := selection.
    1.83 -    cashedSelection isNil ifTrue:[ ^ exceptionBlock value ].
    1.84 -  ^ cashedSelection detect:aBlock ifNone:exceptionBlock
    1.85 +    |keptSelection|
    1.86 +
    1.87 +    "/ the selection may change at any time (may it?)
    1.88 +    (keptSelection := selection) isNil ifTrue:[ ^ exceptionBlock value ].
    1.89 +    ^ keptSelection detect:aBlock ifNone:exceptionBlock
    1.90 +
    1.91 +    "Modified (format): / 12-02-2017 / 11:54:13 / cg"
    1.92  !
    1.93  
    1.94  detectLast:aBlock
    1.95 @@ -4282,11 +4294,13 @@
    1.96       If none of the evaluations returns true, the result of the evaluation
    1.97       of the exceptionBlock is returned
    1.98      "
    1.99 -    |cashedSelection|
   1.100 -
   1.101 -    cashedSelection := selection.
   1.102 -    cashedSelection isNil ifTrue:[ ^ exceptionBlock value ].
   1.103 -  ^ cashedSelection detectLast:aBlock ifNone:exceptionBlock
   1.104 +    |keptSelection|
   1.105 +
   1.106 +    "/ the selection may change at any time (may it?)
   1.107 +    (keptSelection := selection) isNil ifTrue:[ ^ exceptionBlock value ].
   1.108 +    ^ keptSelection detectLast:aBlock ifNone:exceptionBlock
   1.109 +
   1.110 +    "Modified (format): / 12-02-2017 / 11:53:49 / cg"
   1.111  ! !
   1.112  
   1.113  !ViewTreeInspectorApplication::ViewTreeModel methodsFor:'selection testing'!
   1.114 @@ -4294,44 +4308,45 @@
   1.115  includes:anItem
   1.116      "returns true if the item is in the current selection
   1.117      "
   1.118 -    |cashedSelection|
   1.119 -
   1.120 -    cashedSelection := selection.
   1.121 -    cashedSelection isNil ifTrue:[^ false].
   1.122 - ^  cashedSelection includesIdentical:anItem
   1.123 +    |keptSelection|
   1.124 +
   1.125 +    "/ the selection may change at any time (may it?)
   1.126 +    (keptSelection := selection) isNil ifTrue:[^ false].
   1.127 +    ^ keptSelection includesIdentical:anItem
   1.128 +
   1.129 +    "Modified: / 12-02-2017 / 11:51:34 / cg"
   1.130  !
   1.131  
   1.132  includesAll:aCollection
   1.133      "return true, if all items of the collection are included in the current selection
   1.134      "
   1.135 -    |cashedSelection|
   1.136 +    |keptSelection|
   1.137  
   1.138      aCollection size ~~ 0 ifTrue:[
   1.139 -        cashedSelection := selection.
   1.140 -        cashedSelection isNil ifTrue:[ ^ false ].
   1.141 -
   1.142 -        aCollection do:[:el|
   1.143 -            (cashedSelection includesIdentical:el) ifFalse:[^ false]
   1.144 -        ]
   1.145 +        "/ the selection may change at any time (may it?)
   1.146 +        (keptSelection := selection) isNil ifTrue:[ ^ false ].
   1.147 +
   1.148 +        ^ aCollection contains:[:el| (keptSelection includesIdentical:el)]
   1.149      ].
   1.150      ^ true
   1.151 +
   1.152 +    "Modified (format): / 12-02-2017 / 11:51:14 / cg"
   1.153  !
   1.154  
   1.155  includesAny:aCollection
   1.156 -    "return true, if the any item of the collection is in the current selection
   1.157 +    "return true, if any item of the collection is in the current selection
   1.158      "
   1.159 -    |cashedSelection|
   1.160 +    |keptSelection|
   1.161  
   1.162      aCollection notNil ifTrue:[
   1.163 -        cashedSelection := selection.
   1.164 -
   1.165 -        cashedSelection notNil ifTrue:[
   1.166 -            aCollection do:[:el|
   1.167 -                (cashedSelection includesIdentical:el) ifTrue:[^ true]
   1.168 -            ]
   1.169 +        "/ the selection may change at any time (may it?)
   1.170 +        (keptSelection := selection) notNil ifTrue:[
   1.171 +            ^ aCollection contains:[:el| (keptSelection includesIdentical:el)]
   1.172          ]
   1.173      ].
   1.174      ^ false
   1.175 +
   1.176 +    "Modified (format): / 12-02-2017 / 11:50:26 / cg"
   1.177  !
   1.178  
   1.179  includesIdentical:anItem