4069 ! |
4069 ! |
4070 |
4070 |
4071 do:aOneArgBlock |
4071 do:aOneArgBlock |
4072 "evaluate the argument, aBlock for each item in the selection |
4072 "evaluate the argument, aBlock for each item in the selection |
4073 " |
4073 " |
4074 |cashedSelection| |
4074 |keptSelection| |
4075 |
4075 |
4076 cashedSelection := selection. |
4076 "/ the selection may change at any time (may it?) |
4077 cashedSelection isNil ifTrue:[^ nil]. |
4077 (keptSelection := selection) isNil ifTrue:[^ nil]. |
4078 ^ cashedSelection do:aOneArgBlock |
4078 ^ keptSelection do:aOneArgBlock |
|
4079 |
|
4080 "Modified (format): / 12-02-2017 / 11:53:23 / cg" |
4079 ! |
4081 ! |
4080 |
4082 |
4081 from:start do:aOneArgBlock |
4083 from:start do:aOneArgBlock |
4082 "evaluate the argument, aBlock for the items starting at index start |
4084 "evaluate the argument, aBlock for the items starting at index start |
4083 " |
4085 " |
4084 |cashedSelection| |
4086 |keptSelection| |
4085 |
4087 |
4086 cashedSelection := selection. |
4088 "/ the selection may change at any time (may it?) |
4087 cashedSelection isNil ifTrue:[^ nil]. |
4089 (keptSelection := selection) isNil ifTrue:[^ nil]. |
4088 ^ cashedSelection from:start do:aOneArgBlock |
4090 "/ but if so, then start may no longer be valid here?? |
|
4091 ^ keptSelection from:start do:aOneArgBlock |
|
4092 |
|
4093 "Modified (comment): / 12-02-2017 / 11:52:57 / cg" |
4089 ! |
4094 ! |
4090 |
4095 |
4091 from:start to:stop do:aOneArgBlock |
4096 from:start to:stop do:aOneArgBlock |
4092 "evaluate the argument, aBlock for the items with index start to |
4097 "evaluate the argument, aBlock for the items with index start to |
4093 stop in the selection. |
4098 stop in the selection. |
4094 " |
4099 " |
4095 |cashedSelection| |
4100 |keptSelection| |
4096 |
4101 |
4097 cashedSelection := selection. |
4102 "/ the selection may change at any time (may it?) |
4098 cashedSelection isNil ifTrue:[^ nil]. |
4103 (keptSelection := selection) isNil ifTrue:[^ nil]. |
4099 ^ cashedSelection from:start to:stop do:aOneArgBlock |
4104 "/ but if so, then start and stop may no longer be valid here?? |
|
4105 ^ keptSelection from:start to:stop do:aOneArgBlock |
|
4106 |
|
4107 "Modified (comment): / 12-02-2017 / 11:52:25 / cg" |
4100 ! |
4108 ! |
4101 |
4109 |
4102 reverseDo:aOneArgBlock |
4110 reverseDo:aOneArgBlock |
4103 "evaluate the argument, aBlock for each item in the selection |
4111 "evaluate the argument, aBlock for each item in the selection |
4104 " |
4112 " |
4105 |cashedSelection| |
4113 |keptSelection| |
4106 |
4114 |
4107 cashedSelection := selection. |
4115 "/ the selection may change at any time (may it?) |
4108 cashedSelection isNil ifTrue:[^ nil]. |
4116 (keptSelection := selection) isNil ifTrue:[^ nil]. |
4109 ^ cashedSelection reverseDo:aOneArgBlock |
4117 ^ keptSelection reverseDo:aOneArgBlock |
|
4118 |
|
4119 "Modified: / 12-02-2017 / 11:50:02 / cg" |
4110 ! |
4120 ! |
4111 |
4121 |
4112 select:aBlock |
4122 select:aBlock |
4113 "return a new collection with all elements from the selection, for which |
4123 "return a new collection with all elements from the selection, for which |
4114 the argument aBlock evaluates to true. |
4124 the argument aBlock evaluates to true. |
4257 block returns true; in this case return the element which caused the |
4267 block returns true; in this case return the element which caused the |
4258 true evaluation. |
4268 true evaluation. |
4259 If none of the evaluations returns true, the result of the evaluation |
4269 If none of the evaluations returns true, the result of the evaluation |
4260 of the exceptionBlock is returned |
4270 of the exceptionBlock is returned |
4261 " |
4271 " |
4262 |cashedSelection| |
4272 |keptSelection| |
4263 |
4273 |
4264 cashedSelection := selection. |
4274 "/ the selection may change at any time (may it?) |
4265 cashedSelection isNil ifTrue:[ ^ exceptionBlock value ]. |
4275 (keptSelection := selection) isNil ifTrue:[ ^ exceptionBlock value ]. |
4266 ^ cashedSelection detect:aBlock ifNone:exceptionBlock |
4276 ^ keptSelection detect:aBlock ifNone:exceptionBlock |
|
4277 |
|
4278 "Modified (format): / 12-02-2017 / 11:54:13 / cg" |
4267 ! |
4279 ! |
4268 |
4280 |
4269 detectLast:aBlock |
4281 detectLast:aBlock |
4270 "evaluate the argument, aBlock for each item in the selection until |
4282 "evaluate the argument, aBlock for each item in the selection until |
4271 the block returns true; in this case return the element which caused |
4283 the block returns true; in this case return the element which caused |
4280 the block returns true; in this case return the element which caused |
4292 the block returns true; in this case return the element which caused |
4281 the true evaluation. The items are processed in reverse order. |
4293 the true evaluation. The items are processed in reverse order. |
4282 If none of the evaluations returns true, the result of the evaluation |
4294 If none of the evaluations returns true, the result of the evaluation |
4283 of the exceptionBlock is returned |
4295 of the exceptionBlock is returned |
4284 " |
4296 " |
4285 |cashedSelection| |
4297 |keptSelection| |
4286 |
4298 |
4287 cashedSelection := selection. |
4299 "/ the selection may change at any time (may it?) |
4288 cashedSelection isNil ifTrue:[ ^ exceptionBlock value ]. |
4300 (keptSelection := selection) isNil ifTrue:[ ^ exceptionBlock value ]. |
4289 ^ cashedSelection detectLast:aBlock ifNone:exceptionBlock |
4301 ^ keptSelection detectLast:aBlock ifNone:exceptionBlock |
|
4302 |
|
4303 "Modified (format): / 12-02-2017 / 11:53:49 / cg" |
4290 ! ! |
4304 ! ! |
4291 |
4305 |
4292 !ViewTreeInspectorApplication::ViewTreeModel methodsFor:'selection testing'! |
4306 !ViewTreeInspectorApplication::ViewTreeModel methodsFor:'selection testing'! |
4293 |
4307 |
4294 includes:anItem |
4308 includes:anItem |
4295 "returns true if the item is in the current selection |
4309 "returns true if the item is in the current selection |
4296 " |
4310 " |
4297 |cashedSelection| |
4311 |keptSelection| |
4298 |
4312 |
4299 cashedSelection := selection. |
4313 "/ the selection may change at any time (may it?) |
4300 cashedSelection isNil ifTrue:[^ false]. |
4314 (keptSelection := selection) isNil ifTrue:[^ false]. |
4301 ^ cashedSelection includesIdentical:anItem |
4315 ^ keptSelection includesIdentical:anItem |
|
4316 |
|
4317 "Modified: / 12-02-2017 / 11:51:34 / cg" |
4302 ! |
4318 ! |
4303 |
4319 |
4304 includesAll:aCollection |
4320 includesAll:aCollection |
4305 "return true, if all items of the collection are included in the current selection |
4321 "return true, if all items of the collection are included in the current selection |
4306 " |
4322 " |
4307 |cashedSelection| |
4323 |keptSelection| |
4308 |
4324 |
4309 aCollection size ~~ 0 ifTrue:[ |
4325 aCollection size ~~ 0 ifTrue:[ |
4310 cashedSelection := selection. |
4326 "/ the selection may change at any time (may it?) |
4311 cashedSelection isNil ifTrue:[ ^ false ]. |
4327 (keptSelection := selection) isNil ifTrue:[ ^ false ]. |
4312 |
4328 |
4313 aCollection do:[:el| |
4329 ^ aCollection contains:[:el| (keptSelection includesIdentical:el)] |
4314 (cashedSelection includesIdentical:el) ifFalse:[^ false] |
4330 ]. |
|
4331 ^ true |
|
4332 |
|
4333 "Modified (format): / 12-02-2017 / 11:51:14 / cg" |
|
4334 ! |
|
4335 |
|
4336 includesAny:aCollection |
|
4337 "return true, if any item of the collection is in the current selection |
|
4338 " |
|
4339 |keptSelection| |
|
4340 |
|
4341 aCollection notNil ifTrue:[ |
|
4342 "/ the selection may change at any time (may it?) |
|
4343 (keptSelection := selection) notNil ifTrue:[ |
|
4344 ^ aCollection contains:[:el| (keptSelection includesIdentical:el)] |
4315 ] |
4345 ] |
4316 ]. |
4346 ]. |
4317 ^ true |
|
4318 ! |
|
4319 |
|
4320 includesAny:aCollection |
|
4321 "return true, if the any item of the collection is in the current selection |
|
4322 " |
|
4323 |cashedSelection| |
|
4324 |
|
4325 aCollection notNil ifTrue:[ |
|
4326 cashedSelection := selection. |
|
4327 |
|
4328 cashedSelection notNil ifTrue:[ |
|
4329 aCollection do:[:el| |
|
4330 (cashedSelection includesIdentical:el) ifTrue:[^ true] |
|
4331 ] |
|
4332 ] |
|
4333 ]. |
|
4334 ^ false |
4347 ^ false |
|
4348 |
|
4349 "Modified (format): / 12-02-2017 / 11:50:26 / cg" |
4335 ! |
4350 ! |
4336 |
4351 |
4337 includesIdentical:anItem |
4352 includesIdentical:anItem |
4338 "returns true if the item is in the current selection |
4353 "returns true if the item is in the current selection |
4339 " |
4354 " |