diff --git a/src/Toplo-Widget-List-Tests/ToSelectionModelTest.class.st b/src/Toplo-Widget-List-Tests/ToSelectionModelTest.class.st index bec47b61c..27f9fe04b 100644 --- a/src/Toplo-Widget-List-Tests/ToSelectionModelTest.class.st +++ b/src/Toplo-Widget-List-Tests/ToSelectionModelTest.class.st @@ -142,6 +142,20 @@ ToSelectionModelTest >> testDeselectIndex [ self assert: s selectedIndexes asSet equals: { 1. } asSet ] +{ #category : #tests } +ToSelectionModelTest >> testDeselectIndexTo [ + + | s | + s := ToSelectionModel new itemCountGetter: 100. + s selectIndex: 5 to: 15. + s deselectIndex: 8 to: 12. + self assert: s selectedIndexes equals: { 5. 6. 7. 13. 14. 15 }. + s deselectAll. + s selectIndex: 5 to: 15. + s deselectIndex: 12 to: 8. + self assert: s selectedIndexes equals: { 5. 6. 7. 13. 14. 15 } +] + { #category : #tests } ToSelectionModelTest >> testEnsureCompositeSelectionModel [ @@ -182,6 +196,23 @@ ToSelectionModelTest >> testEquals [ s ensureWholeSelectionModel. self deny: s equals: ToSelectionModel new. +] + +{ #category : #tests } +ToSelectionModelTest >> testFirstIndex [ + + | s | + s := ToSelectionModel new. + self should: [ s firstIndex ] raise: Error. + s itemCountGetter: [ 100 ]. + self assert: s firstIndex equals: 0. + s selectAllIndexes: #( 4 6 8). + self assert: s firstIndex equals: 4. + s selectAll. + self assert: s firstIndex equals: 1. + + + ] { #category : #tests } @@ -235,6 +266,20 @@ ToSelectionModelTest >> testItemCountGetter [ ] +{ #category : #tests } +ToSelectionModelTest >> testLastIndex [ + + | s | + s := ToSelectionModel new. + self should: [ s lastIndex ] raise: Error. + s itemCountGetter: [ 100 ]. + self assert: s lastIndex equals: 0. + s selectAllIndexes: #( 4 6 8 ). + self assert: s lastIndex equals: 8. + s selectAll. + self assert: s lastIndex equals: 100 +] + { #category : #tests } ToSelectionModelTest >> testNewOperator [ @@ -304,6 +349,80 @@ ToSelectionModelTest >> testSelectIndex [ self assert: s selectedIndexes asSet equals: { 1. 5. 6. 10. 50. 60 } asSet ] +{ #category : #tests } +ToSelectionModelTest >> testSelectIndexTo [ + + | s | + s := ToSelectionModel new itemCountGetter: 100. + s selectIndex: 5 to: 9. + self assert: (s underlyingModel isKindOf: ToCompositeSelectionModel ). + self assert: s selectedIndexes equals: { 5. 6. 7. 8. 9 }. + s selectIndex: 15 to: 10. + self assert: s selectedIndexes equals: { 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15 } +] + +{ #category : #tests } +ToSelectionModelTest >> testSelectedIndexesCollect [ + + | s collected | + s := ToSelectionModel new. + self should: [ s selectedIndexesDo: [ :idx | ] ] raise: Error. + s itemCountGetter: [ 100 ]. + collected := s selectedIndexesCollect: [ :idx | idx ]. + self assert: collected equals: #( ). + s selectAllIndexes: #( 4 6 8 ). + collected := s selectedIndexesCollect: [ :idx | idx ]. + self assert: collected equals: #( 4 6 8 ). + s deselectAll. + collected := s selectedIndexesCollect: [ :idx | idx ]. + self assert: collected equals: #( ). + s selectAll. + collected := s selectedIndexesCollect: [ :idx | idx ]. + self assert: collected equals: (( 1 to: 100 ) collect: [:idx | idx]). + +] + +{ #category : #tests } +ToSelectionModelTest >> testSelectedIndexesCount [ + + | s | + s := ToSelectionModel new. + self should: [ s selectedIndexesCount ] raise: Error. + s itemCountGetter: [ 100 ]. + self assert: s selectedIndexesCount equals: 0. + s selectAllIndexes: #( 4 6 8 ). + self assert: s selectedIndexesCount equals: 3. + s deselectAll. + self assert: s selectedIndexesCount equals: 0. + s selectAll. + self assert: s selectedIndexesCount equals: 100 +] + +{ #category : #tests } +ToSelectionModelTest >> testSelectedIndexesDo [ + + | s count | + s := ToSelectionModel new. + self should: [ s selectedIndexesDo: [ :idx | ] ] raise: Error. + s itemCountGetter: [ 100 ]. + count := 0. + s selectedIndexesDo: [ :idx | count := count + 1 ]. + self assert: count equals: 0. + s selectAllIndexes: #( 4 6 8 ). + count := 0. + s selectedIndexesDo: [ :idx | count := count + 1 ]. + self assert: count equals: 3. + s deselectAll. + count := 0. + s selectedIndexesDo: [ :idx | count := count + 1 ]. + self assert: count equals: 0. + s selectAll. + count := 0. + s selectedIndexesDo: [ :idx | count := count + 1 ]. + self assert: count equals: 100. + +] + { #category : #tests } ToSelectionModelTest >> testSelectedItemCount [ diff --git a/src/Toplo-Widget-List/TToCommandOperator.trait.st b/src/Toplo-Widget-List/TToCommandOperator.trait.st index 5c822281a..c906c2131 100644 --- a/src/Toplo-Widget-List/TToCommandOperator.trait.st +++ b/src/Toplo-Widget-List/TToCommandOperator.trait.st @@ -30,3 +30,9 @@ TToCommandOperator >> applyCommand: aCommand for: aTarget [ aCommand applyOn: self for: aTarget. ] + +{ #category : #'event management' } +TToCommandOperator >> dispatchEvent: anEvent [ + + self explicitRequirement +] diff --git a/src/Toplo-Widget-List/ToDataWithPosition.class.st b/src/Toplo-Widget-List/ToDataWithPosition.class.st deleted file mode 100644 index db8134859..000000000 --- a/src/Toplo-Widget-List/ToDataWithPosition.class.st +++ /dev/null @@ -1,33 +0,0 @@ -Class { - #name : #ToDataWithPosition, - #superclass : #Object, - #instVars : [ - 'data', - 'dataSourcePos' - ], - #category : #'Toplo-Widget-List-Filter' -} - -{ #category : #accessing } -ToDataWithPosition >> data [ - - ^ data -] - -{ #category : #accessing } -ToDataWithPosition >> data: anObject [ - - data := anObject -] - -{ #category : #accessing } -ToDataWithPosition >> dataSourcePos [ - - ^ dataSourcePos -] - -{ #category : #accessing } -ToDataWithPosition >> dataSourcePos: anInteger [ - - dataSourcePos := anInteger -] diff --git a/src/Toplo-Widget-List/ToFilteredListElementEventHandler.class.st b/src/Toplo-Widget-List/ToFilteredListElementEventHandler.class.st deleted file mode 100644 index 42c621208..000000000 --- a/src/Toplo-Widget-List/ToFilteredListElementEventHandler.class.st +++ /dev/null @@ -1,129 +0,0 @@ -Class { - #name : #ToFilteredListElementEventHandler, - #superclass : #BlCustomEventHandler, - #instVars : [ - 'filter', - 'updatingSelection', - 'selectionModel' - ], - #category : #'Toplo-Widget-List-Filter' -} - -{ #category : #'api - accessing' } -ToFilteredListElementEventHandler >> eventsToHandle [ - - ^ { - ToListFilterRequest. - ToListFilterResultEvent. - ToListSelectionChangedEvent. - ToFilteredListSelectionModelChangedEvent } -] - -{ #category : #accessing } -ToFilteredListElementEventHandler >> filter: aListElementFilter [ - - filter := aListElementFilter -] - -{ #category : #'event handlers' } -ToFilteredListElementEventHandler >> filteredListSelectionModelChangedEvent: anEvent [ - - | target selectedIndexes deselectedIndexes | - target := anEvent currentTarget. - selectedIndexes := OrderedCollection new. - deselectedIndexes := OrderedCollection new. - updatingSelection := true. - - filter currentIndexedData withIndexDo: [ :idata :idx | - (self selectionModel containsIndex: idata dataSourcePos) - ifTrue: [ selectedIndexes add: idx ] - ifFalse: [ deselectedIndexes add: idx ] ]. - - target selectionStrategy deselectAll. - target selectionStrategy selectIndexes: selectedIndexes. - self flag: 'TODO: check with . I''m not sure it works ( and it must work ) but now its time to go to sleep... '. - - updatingSelection := false -] - -{ #category : #initialization } -ToFilteredListElementEventHandler >> initialize [ - - super initialize. - updatingSelection := false -] - -{ #category : #'event handlers' } -ToFilteredListElementEventHandler >> listFilterRequest: anEvent [ - - | target | - target := anEvent currentTarget. - filter pattern: anEvent pattern - -] - -{ #category : #'event handlers' } -ToFilteredListElementEventHandler >> listFilterResultEvent: anEvent [ - - | target selectedIndexes result | - target := anEvent currentTarget. - " target is the filtered listElement (pattern dependent) " - " selectionModel is the original (global, pattern independent) selection model " - target selectionStrategy renewSelectionModel. - updatingSelection := true. - " result is the filter result data list (pattern dependent)" - result := OrderedCollection new. - " selected indexes is for the filtered list (pattern dependent) " - selectedIndexes := OrderedCollection new. - " anEvent indexedData : list of ToFilterData, (pattern dependent" - anEvent indexedData withIndexDo: [ :id :idx | - result add: id data. - "dataSourcePos is the original data index (pattern independent)" - (self selectionModel containsIndex: id dataSourcePos) ifTrue: [ - selectedIndexes add: idx ] ]. - target data filterResult: result. - target selectionStrategy doSelectAllIndexes: selectedIndexes. - updatingSelection := false -] - -{ #category : #'event handlers' } -ToFilteredListElementEventHandler >> listSelectionChangedEvent: anEvent [ - - | target | - updatingSelection ifTrue: [ ^ self ]. - filter currentIndexedData ifNil: [ ^ self ]. - target := anEvent currentTarget. - - " the target is the filtered listElement " - 1 to: target data size do: [ :pos | - | dataWithIndex | - dataWithIndex := filter currentIndexedData at: pos. - (target selectionStrategy includes: pos) - ifTrue: [ self selectionModel selectIndex: dataWithIndex dataSourcePos ] - ifFalse: [ self selectionModel deselectIndex: dataWithIndex dataSourcePos ] ]. - - target dispatchEvent: (ToFilteredListSelectionChangedEvent new - selection: self selectionModel; - yourself) -] - -{ #category : #'api - hooks' } -ToFilteredListElementEventHandler >> onUninstalledIn: anElement [ - - super onUninstalledIn: anElement. - filter := nil. - selectionModel := nil - -] - -{ #category : #accessing } -ToFilteredListElementEventHandler >> selectionModel [ - - ^ selectionModel -] - -{ #category : #accessing } -ToFilteredListElementEventHandler >> selectionModel: aSelectionModel [ - - selectionModel := aSelectionModel -] diff --git a/src/Toplo-Widget-List/ToFilteredListPatternChangedEvent.class.st b/src/Toplo-Widget-List/ToFilteredListPatternChangedEvent.class.st deleted file mode 100644 index c31b5a057..000000000 --- a/src/Toplo-Widget-List/ToFilteredListPatternChangedEvent.class.st +++ /dev/null @@ -1,26 +0,0 @@ -Class { - #name : #ToFilteredListPatternChangedEvent, - #superclass : #BlEvent, - #instVars : [ - 'pattern' - ], - #category : #'Toplo-Widget-List-Filter' -} - -{ #category : #accessing } -ToFilteredListPatternChangedEvent >> pattern [ - - ^ pattern -] - -{ #category : #accessing } -ToFilteredListPatternChangedEvent >> pattern: anObject [ - - pattern := anObject -] - -{ #category : #sending } -ToFilteredListPatternChangedEvent >> sendTo: anObject [ - - anObject filteredListPatternChangedEvent: self -] diff --git a/src/Toplo-Widget-List/ToFilteredListSelectionChangedEvent.class.st b/src/Toplo-Widget-List/ToFilteredListSelectionChangedEvent.class.st deleted file mode 100644 index f420888b4..000000000 --- a/src/Toplo-Widget-List/ToFilteredListSelectionChangedEvent.class.st +++ /dev/null @@ -1,26 +0,0 @@ -Class { - #name : #ToFilteredListSelectionChangedEvent, - #superclass : #BlEvent, - #instVars : [ - 'selection' - ], - #category : #'Toplo-Widget-List-Filter' -} - -{ #category : #accessing } -ToFilteredListSelectionChangedEvent >> selection [ - - ^ selection -] - -{ #category : #accessing } -ToFilteredListSelectionChangedEvent >> selection: aSelectionModel [ - - selection := aSelectionModel -] - -{ #category : #sending } -ToFilteredListSelectionChangedEvent >> sendTo: anObject [ - - anObject filteredListSelectionChangedEvent: self -] diff --git a/src/Toplo-Widget-List/ToFilteredListSelectionModelChangedEvent.class.st b/src/Toplo-Widget-List/ToFilteredListSelectionModelChangedEvent.class.st deleted file mode 100644 index f4df88a48..000000000 --- a/src/Toplo-Widget-List/ToFilteredListSelectionModelChangedEvent.class.st +++ /dev/null @@ -1,26 +0,0 @@ -Class { - #name : #ToFilteredListSelectionModelChangedEvent, - #superclass : #BlEvent, - #instVars : [ - 'selection' - ], - #category : #'Toplo-Widget-List-Filter' -} - -{ #category : #accessing } -ToFilteredListSelectionModelChangedEvent >> selection [ - - ^ selection -] - -{ #category : #accessing } -ToFilteredListSelectionModelChangedEvent >> selection: aSelectionModel [ - - selection := aSelectionModel -] - -{ #category : #sending } -ToFilteredListSelectionModelChangedEvent >> sendTo: anObject [ - - anObject filteredListSelectionModelChangedEvent: self -] diff --git a/src/Toplo-Widget-List/ToListElementFilter.class.st b/src/Toplo-Widget-List/ToListElementFilter.class.st deleted file mode 100644 index dc052d85a..000000000 --- a/src/Toplo-Widget-List/ToListElementFilter.class.st +++ /dev/null @@ -1,224 +0,0 @@ -Class { - #name : #ToListElementFilter, - #superclass : #Object, - #instVars : [ - 'pattern', - 'semaphore', - 'process', - 'originalData', - 'delayBeforeFilter', - 'filterResultTask', - 'taskQueueHolder', - 'previousPattern', - 'originalIndexedData', - 'dataFilter', - 'filterListElementHandler', - 'selectionModel', - 'currentIndexedData', - 'collectionAfterChangeEventHandler', - 'filteredListElement' - ], - #category : #'Toplo-Widget-List-Filter' -} - -{ #category : #'private filtering' } -ToListElementFilter >> buildOriginalIndexedData [ - - originalIndexedData := Array streamContents: [ :str | - originalData withIndexDo: [ :d :i | - str nextPut: (ToDataWithPosition new - data: d; - dataSourcePos: i; - yourself) ] ] -] - -{ #category : #accessing } -ToListElementFilter >> currentIndexedData [ - - ^ currentIndexedData ifNil: [ originalIndexedData ] -] - -{ #category : #accessing } -ToListElementFilter >> dataFilter [ - - ^ dataFilter ifNil: [ dataFilter := self defaultFilter ] -] - -{ #category : #accessing } -ToListElementFilter >> dataFilter: aValuable [ - " filter takes a data and a pattern as argument " - - dataFilter := aValuable -] - -{ #category : #accessing } -ToListElementFilter >> defaultDelay [ - - ^ 250 milliSeconds -] - -{ #category : #accessing } -ToListElementFilter >> defaultFilter [ - - "^ [ :data :p | data includesSubstring: p caseSensitive: false ]" - ^ [ :aData :aPattern | aData asString beginsWith: aPattern caseSensitive: true ] -] - -{ #category : #accessing } -ToListElementFilter >> delayBeforeFilter [ - - ^ delayBeforeFilter -] - -{ #category : #'private filtering' } -ToListElementFilter >> filterDataIn: anElement [ - - | event taskTarget | - - anElement dispatchEvent: (ToFilteredListPatternChangedEvent new - pattern: self pattern; - yourself). - - taskTarget := taskQueueHolder ifNil: [ anElement ]. - self pattern - ifEmpty: [ currentIndexedData := originalIndexedData ] - ifNotEmpty: [ - currentIndexedData := Array streamContents: [ :str | - originalIndexedData do: [ :d | - (self dataFilter value: d data value: self pattern) - ifTrue: [ str nextPut: d ] ] ] ]. - - "A task must be used here because the filtering is runned asynchronously. The task allows to re-synchronise the element response - ( and then to be runned in the UI thread ). - As an example, it can avoid the children updating during layouting (because during layouting children are temporarily detached) - (which leads to errors related to children adding and which are difficult to understand)" - - filterResultTask ifNotNil: [ - taskTarget dequeueTask: filterResultTask ]. - filterResultTask := BlTaskAction new. - filterResultTask action: [ - event := ToListFilterResultEvent new. - event - pattern: self pattern; - indexedData: currentIndexedData. - anElement dispatchEvent: event. - filterResultTask := nil ]. - taskTarget enqueueTask: filterResultTask -] - -{ #category : #accessing } -ToListElementFilter >> filteredListElement [ - - ^ filteredListElement -] - -{ #category : #'private filtering' } -ToListElementFilter >> newProcessIn: anElement [ - "Used the solution implemented in FastTable. see FTFieldFunction>>#spawnFilterUpdateThread. - Runs in background, thank to Henrik Johansen for this" - - semaphore := Semaphore new. - ^ [ - [ - self semaphore wait. - - pattern ifNotEmpty: [ self delayBeforeFilter wait ]. - - previousPattern = pattern ifFalse: [ - previousPattern := pattern. - self filterDataIn: anElement ] ] repeat ] - forkAt: Processor userBackgroundPriority - named: self class name , ' filter process' -] - -{ #category : #'api - hooks' } -ToListElementFilter >> onInstalledIn: aListElement [ - - filteredListElement := aListElement. - self originalData: aListElement data newMirror. - delayBeforeFilter := self defaultDelay. - - filterListElementHandler := ToFilteredListElementEventHandler new - selectionModel: self selectionModel; - filter: self; - yourself. - aListElement addEventHandler: filterListElementHandler. - process := self newProcessIn: aListElement. - aListElement data updateAllWith: originalData -] - -{ #category : #'api - hooks' } -ToListElementFilter >> onUninstalledIn: aListElement [ - - process terminate. - aListElement removeEventHandler: filterListElementHandler. - originalData ifNotNil: [ - originalData removeEventHandler: collectionAfterChangeEventHandler ]. - originalData := nil. - pattern := ''. - semaphore := nil -] - -{ #category : #accessing } -ToListElementFilter >> originalData [ - - ^ originalData -] - -{ #category : #accessing } -ToListElementFilter >> originalData: anObservableCollection [ - - originalData = anObservableCollection ifTrue: [ ^ self ]. - originalData ifNotNil: [ ^ (BlImmutableObjectChangeError object: self) signal ]. - originalData := anObservableCollection. - collectionAfterChangeEventHandler := BlEventHandler - on: ToCollectionAfterChangeEvent - do: [ self buildOriginalIndexedData ]. - originalData addEventHandler: collectionAfterChangeEventHandler. - self buildOriginalIndexedData -] - -{ #category : #accessing } -ToListElementFilter >> pattern [ - - ^ pattern ifNil: [ pattern := '' ] -] - -{ #category : #'private filtering' } -ToListElementFilter >> pattern: aString [ - - pattern = aString ifTrue: [ ^ self ]. - pattern := aString asString trimBoth. - previousPattern = pattern ifTrue: [ ^ self ]. - self semaphore signal -] - -{ #category : #accessing } -ToListElementFilter >> selectionModel [ - - ^ selectionModel ifNil: [ selectionModel := BlCompositeSelection new ] -] - -{ #category : #accessing } -ToListElementFilter >> selectionModel: aSelectionModel [ - - selectionModel := aSelectionModel -] - -{ #category : #accessing } -ToListElementFilter >> semaphore [ - - ^ semaphore -] - -{ #category : #accessing } -ToListElementFilter >> taskQueueHolder [ - - ^ taskQueueHolder -] - -{ #category : #accessing } -ToListElementFilter >> taskQueueHolder: aTaskQueueHolder [ - - taskQueueHolder := aTaskQueueHolder -] diff --git a/src/Toplo-Widget-List/ToListFilterRequest.class.st b/src/Toplo-Widget-List/ToListFilterRequest.class.st deleted file mode 100644 index ce8eea6d8..000000000 --- a/src/Toplo-Widget-List/ToListFilterRequest.class.st +++ /dev/null @@ -1,26 +0,0 @@ -Class { - #name : #ToListFilterRequest, - #superclass : #BlEvent, - #instVars : [ - 'pattern' - ], - #category : #'Toplo-Widget-List-Filter' -} - -{ #category : #accessing } -ToListFilterRequest >> pattern [ - - ^ pattern -] - -{ #category : #accessing } -ToListFilterRequest >> pattern: anObject [ - - pattern := anObject -] - -{ #category : #sending } -ToListFilterRequest >> sendTo: anObject [ - - anObject listFilterRequest: self -] diff --git a/src/Toplo-Widget-List/ToListFilterResultEvent.class.st b/src/Toplo-Widget-List/ToListFilterResultEvent.class.st deleted file mode 100644 index 72a8602d9..000000000 --- a/src/Toplo-Widget-List/ToListFilterResultEvent.class.st +++ /dev/null @@ -1,39 +0,0 @@ -Class { - #name : #ToListFilterResultEvent, - #superclass : #BlEvent, - #instVars : [ - 'pattern', - 'indexedData' - ], - #category : #'Toplo-Widget-List-Filter' -} - -{ #category : #accessing } -ToListFilterResultEvent >> indexedData [ - - ^ indexedData -] - -{ #category : #accessing } -ToListFilterResultEvent >> indexedData: aListElementFilterDataCollection [ - - indexedData := aListElementFilterDataCollection -] - -{ #category : #accessing } -ToListFilterResultEvent >> pattern [ - - ^ pattern -] - -{ #category : #accessing } -ToListFilterResultEvent >> pattern: anObject [ - - pattern := anObject -] - -{ #category : #sending } -ToListFilterResultEvent >> sendTo: anObject [ - - anObject listFilterResultEvent: self -] diff --git a/src/Toplo-Widget-List/ToListSelectionChangedEvent.class.st b/src/Toplo-Widget-List/ToListSelectionChangedEvent.class.st index 1d87bc1cf..845605478 100644 --- a/src/Toplo-Widget-List/ToListSelectionChangedEvent.class.st +++ b/src/Toplo-Widget-List/ToListSelectionChangedEvent.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'selectionModel' ], - #category : #'Toplo-Widget-List-Selection-Strategy' + #category : #'Toplo-Widget-List-Selection-Events' } { #category : #accessing } diff --git a/src/Toplo-Widget-List/ToListSelectionDirtyEvent.class.st b/src/Toplo-Widget-List/ToListSelectionDirtyEvent.class.st index 2dd1112dd..cc3d1fdd3 100644 --- a/src/Toplo-Widget-List/ToListSelectionDirtyEvent.class.st +++ b/src/Toplo-Widget-List/ToListSelectionDirtyEvent.class.st @@ -1,7 +1,7 @@ Class { #name : #ToListSelectionDirtyEvent, #superclass : #ToListSelectionEvent, - #category : #'Toplo-Widget-List-Selection-Strategy' + #category : #'Toplo-Widget-List-Selection-Events' } { #category : #sending } diff --git a/src/Toplo-Widget-List/ToListSelectionEvent.class.st b/src/Toplo-Widget-List/ToListSelectionEvent.class.st index 28d722569..0e45bc3a8 100644 --- a/src/Toplo-Widget-List/ToListSelectionEvent.class.st +++ b/src/Toplo-Widget-List/ToListSelectionEvent.class.st @@ -1,5 +1,5 @@ Class { #name : #ToListSelectionEvent, #superclass : #BlEvent, - #category : #'Toplo-Widget-List-Selection-Strategy' + #category : #'Toplo-Widget-List-Selection-Events' } diff --git a/src/Toplo-Widget-List/ToListSelectionModeChangedEvent.class.st b/src/Toplo-Widget-List/ToListSelectionModeChangedEvent.class.st index 0da22b66d..84115c806 100644 --- a/src/Toplo-Widget-List/ToListSelectionModeChangedEvent.class.st +++ b/src/Toplo-Widget-List/ToListSelectionModeChangedEvent.class.st @@ -1,7 +1,7 @@ Class { #name : #ToListSelectionModeChangedEvent, #superclass : #ToListSelectionEvent, - #category : #'Toplo-Widget-List-Selection-Strategy' + #category : #'Toplo-Widget-List-Selection-Events' } { #category : #sending } diff --git a/src/Toplo-Widget-List/ToListStrongSelectionEvent.class.st b/src/Toplo-Widget-List/ToListStrongSelectionEvent.class.st index 65d32ffb1..e86570a37 100644 --- a/src/Toplo-Widget-List/ToListStrongSelectionEvent.class.st +++ b/src/Toplo-Widget-List/ToListStrongSelectionEvent.class.st @@ -4,7 +4,7 @@ Class { #instVars : [ 'indexes' ], - #category : #'Toplo-Widget-List-Selection-Strategy' + #category : #'Toplo-Widget-List-Selection-Events' } { #category : #accessing } diff --git a/src/Toplo-Widget-List/ToSelectionModel.class.st b/src/Toplo-Widget-List/ToSelectionModel.class.st index 434e4e70c..204d57145 100644 --- a/src/Toplo-Widget-List/ToSelectionModel.class.st +++ b/src/Toplo-Widget-List/ToSelectionModel.class.st @@ -63,10 +63,13 @@ ToSelectionModel >> deselectIndex: anIndex [ { #category : #updating } ToSelectionModel >> deselectIndex: aFirstIndex to: aSecondIndex [ + | from to | self ensureCompositeSelectionModel. + from := aFirstIndex min: aSecondIndex. + to := aFirstIndex max: aSecondIndex. self underlyingModel - deselect: aFirstIndex - 1 - to: aSecondIndex + deselect: from - 1 + to: to ] { #category : #private } @@ -232,10 +235,13 @@ ToSelectionModel >> selectIndex: anIndex [ { #category : #updating } ToSelectionModel >> selectIndex: aFirstIndex to: aSecondIndex [ + | from to | self ensureCompositeSelectionModel. + from := aFirstIndex min: aSecondIndex. + to := aFirstIndex max: aSecondIndex. self underlyingModel - select: aFirstIndex - 1 - to: aSecondIndex + select: from - 1 + to: to ] { #category : #accessing }