Skip to content
Permalink
Browse files

Merge pull request #779 from jecisc/harvest-pharo-changes

harvest-pharo-changes
  • Loading branch information...
jecisc committed Sep 13, 2019
2 parents 978220b + b9ec358 commit ef8835ad5e200b041391e157ec71324ff90edd31
Showing with 400 additions and 87 deletions.
  1. +31 −0 src/Spec2-Adapters-Morphic/SpAbstractMorphicListAdapter.class.st
  2. +3 −1 src/Spec2-Adapters-Morphic/SpMorphicListAdapter.class.st
  3. +3 −1 src/Spec2-Adapters-Morphic/SpMorphicTableAdapter.class.st
  4. +12 −15 src/Spec2-Backend-Tests/SpAbstractAdapterTest.class.st
  5. +7 −0 src/Spec2-Backend-Tests/SpAbstractListCommonPropertiestTest.class.st
  6. +63 −7 src/Spec2-Backend-Tests/SpListCommonPropertiestTest.class.st
  7. +4 −4 src/Spec2-Commander2-ContactBook/SpPrintContactBookInTranscript.class.st
  8. +8 −1 src/Spec2-Core/SpAbstractListPresenter.class.st
  9. +1 −1 src/Spec2-Core/SpObservableSlot.class.st
  10. +23 −0 src/Spec2-Core/SpPresenter.class.st
  11. +5 −5 src/Spec2-Core/SpVersatileDialogPresenter.class.st
  12. +56 −0 src/Spec2-Core/SpVerticalAlignment.class.st
  13. +1 −1 src/Spec2-Core/SpWidgetBuilt.class.st
  14. +32 −0 src/Spec2-Core/SpWidgetDisplayed.class.st
  15. +8 −2 src/Spec2-Core/SpWindowPresenter.class.st
  16. +1 −1 src/Spec2-Deprecated/SpFastTablePresenter.class.st
  17. +6 −6 src/Spec2-Examples/SpDemoListsPresenter.class.st
  18. +6 −6 src/Spec2-Examples/SpDemoTreeTablePresenter.class.st
  19. +12 −0 src/Spec2-Pharo7To8Compatibility/FTScrollingChanged.class.st
  20. +16 −0 src/Spec2-Pharo7To8Compatibility/FTTableContainerMorph.extension.st
  21. +16 −0 src/Spec2-Pharo7To8Compatibility/FTTableMorph.extension.st
  22. +2 −4 src/Spec2-Tests/SpListPresenterMultipleSelectionTest.class.st
  23. +2 −4 src/Spec2-Tests/SpListPresenterSingleSelectionTest.class.st
  24. +61 −0 src/Spec2-Tests/SpTest.class.st
  25. +16 −20 src/Spec2-Tests/SpWindowPresenterTest.class.st
  26. +5 −8 src/Spec2-Tools/KeymapBrowser.class.st
@@ -0,0 +1,31 @@
"
I am an abstract class with common behaviour for list and table adapters.
See my subclasses for more details.
"
Class {
#name : #SpAbstractMorphicListAdapter,
#superclass : #SpAbstractMorphicAdapter,
#category : #'Spec2-Adapters-Morphic-List'
}

{ #category : #testing }
SpAbstractMorphicListAdapter class >> isAbstract [
^ self = SpAbstractMorphicListAdapter
]

{ #category : #scrolling }
SpAbstractMorphicListAdapter >> configureScrolling [
self presenter verticalAlignment whenChangedDo: [ widget scrollToIndex: self presenter verticalAlignment desiredVisibleRow ].
self presenter
whenDisplayDo: [ widget scrollToIndex: self presenter verticalAlignment desiredVisibleRow.
self scrollingChanged ].
widget onAnnouncement: FTScrollingChanged send: #scrollingChanged to: self
]

{ #category : #scrolling }
SpAbstractMorphicListAdapter >> scrollingChanged [
widget container updateAllRows.
self presenter verticalAlignment
firstVisibleRowIndex: widget firstVisibleRowIndex;
lastVisibleRowIndex: widget lastVisibleRowIndex
]
@@ -3,7 +3,7 @@ I am the adapter used to bridge a ListPresenter and a PluggableListMorph
"
Class {
#name : #SpMorphicListAdapter,
#superclass : #SpAbstractMorphicAdapter,
#superclass : #SpAbstractMorphicListAdapter,
#category : #'Spec2-Adapters-Morphic-List'
}

@@ -53,6 +53,7 @@ SpMorphicListAdapter >> buildWidget [
onAnnouncement: FTSelectionChanged send: #selectionChanged: to: self;
onAnnouncement: FTStrongSelectionChanged send: #strongSelectionChanged: to: self;
yourself.

self presenter whenModelChangedDo: [ widget refresh ].
self presenter whenSelectionChangedDo: [ self refreshWidgetSelection ].
self presenter selection whenChangedDo: [ self refreshWidgetSelection ].
@@ -61,6 +62,7 @@ SpMorphicListAdapter >> buildWidget [
self presenter whenItemFilterBlockChangedDo: [ :block | self updateItemFilterBlockWith: block ].
self updateItemFilterBlockWith: self itemFilter.

self configureScrolling.
widget bindKeyCombination: Character space toAction: [ self model clickOnSelectedItem ].

^ widget
@@ -1,6 +1,6 @@
Class {
#name : #SpMorphicTableAdapter,
#superclass : #SpAbstractMorphicAdapter,
#superclass : #SpAbstractMorphicListAdapter,
#category : #'Spec2-Adapters-Morphic-Table'
}

@@ -28,6 +28,8 @@ SpMorphicTableAdapter >> addModelTo: tableMorph [

tableMorph setBalloonText: self help.

self configureScrolling.

tableMorph
onAnnouncement: FTSelectionChanged
send: #selectionChanged:
@@ -91,16 +91,18 @@ SpAbstractAdapterTest >> openInstance [

{ #category : #private }
SpAbstractAdapterTest >> performTest [

specInitializationStrategy beforeTest: self.
super performTest.
backendForTest
runTest: [ presenter := self classToTest new.
self initializeTestedInstance.
super performTest ]
]

{ #category : #running }
SpAbstractAdapterTest >> prepareToRunAgain [
"Redefined because setup is cancelled in this class"

backendForTest runTest: [ super prepareToRunAgain ]

self tearDown.
super setUp
]

{ #category : #accessing }
@@ -110,16 +112,11 @@ SpAbstractAdapterTest >> presenter [

{ #category : #running }
SpAbstractAdapterTest >> runCase [

self resources do: [:each | each availableFor: self].
[ super setUp.
backendForTest runTest: [
presenter := self classToTest new.
self initializeTestedInstance.
self performTest].
] ensure: [
self tearDown.
self cleanUpInstanceVariables]
self resources do: [ :each | each availableFor: self ].
[ super setUp.
self performTest ]
ensure: [ self tearDown.
self cleanUpInstanceVariables ]
]

{ #category : #running }
@@ -36,6 +36,13 @@ SpAbstractListCommonPropertiestTest >> testDoubleClickActivatesRowInDoubleClickA
self assert: activated
]

{ #category : #'tests - scrolling' }
SpAbstractListCommonPropertiestTest >> testFirstVisibleRowIsInitiallyFirstRow [
presenter items: (1 to: 500).
self openInstance.
self assert: presenter verticalAlignment firstVisibleRowIndex equals: 1
]

{ #category : #tests }
SpAbstractListCommonPropertiestTest >> testRightClickShowsMenu [
| menu |
@@ -9,23 +9,23 @@ SpListCommonPropertiestTest >> classToTest [
^ SpListPresenter
]

{ #category : #running }
{ #category : #tests }
SpListCommonPropertiestTest >> testChangingFromMultipleToSingleSelection [
presenter beMultipleSelection.
self assert: presenter isMultipleSelection.
presenter beSingleSelection.
self deny: presenter isMultipleSelection
]

{ #category : #running }
{ #category : #tests }
SpListCommonPropertiestTest >> testChangingFromSingleToMultipleSelection [
presenter beSingleSelection.
self deny: presenter isMultipleSelection.
presenter beMultipleSelection.
self assert: presenter isMultipleSelection
]

{ #category : #running }
{ #category : #tests }
SpListCommonPropertiestTest >> testEnablingFilteringUpdateOpenedList [
self deny: self adapter hasFilter.
presenter enableItemSubstringFilter.
@@ -34,17 +34,73 @@ SpListCommonPropertiestTest >> testEnablingFilteringUpdateOpenedList [
self deny: self adapter hasFilter
]

{ #category : #running }
{ #category : #tests }
SpListCommonPropertiestTest >> testRemoveHeaderTitleInPresenterRemovesColumnHeaderMorph [
SystemVersion current major = 7 ifTrue: [ "Test failing in Pharo7 due to a bug in FastTable" ^ self skip ].
self flag: #pharo7.
SystemVersion current major < 8 ifTrue: [ self skip. "Feature not supported in Pharo 7" ].

self presenter headerTitle: 'test'.
self presenter hideHeaderTitle.

backendForTest denyHasHeader: self adapter
]

{ #category : #running }
{ #category : #'tests - scrolling' }
SpListCommonPropertiestTest >> testScrollDownToNonExistingIndexScrollsBottomToLastIndex [
self flag: #pharo7.
SystemVersion current major < 8 ifTrue: [ self skip. "Feature not supported in Pharo 7" ].
presenter items: (1 to: 500).
presenter verticalAlignment desiredVisibleRow: 600.

"Force opening the spec instance here.
We want to test that once open we can change the state"
self openInstance.

self assert: presenter verticalAlignment lastVisibleRowIndex equals: 500
]

{ #category : #'tests - scrolling' }
SpListCommonPropertiestTest >> testScrollDownToPosteriorIndexScrollsBottomToIndex [
self flag: #pharo7.
SystemVersion current major < 8 ifTrue: [ self skip. "Feature not supported in Pharo 7" ].
presenter items: (1 to: 500).
presenter verticalAlignment desiredVisibleRow: 100.

"Force opening the spec instance here.
We want to test that once open we can change the state"
self openInstance.

"Some backends will show entirely row 100 and a part of the next row, so row 101 is also a valid answer"
self assert: (presenter verticalAlignment lastVisibleRowIndex between: 100 and: 101)
]

{ #category : #'tests - scrolling' }
SpListCommonPropertiestTest >> testScrollUpToNegativeIndexScrollsTopToFirstIndex [
self flag: #pharo7.
SystemVersion current major < 8 ifTrue: [ self skip. "Feature not supported in Pharo 7" ].
presenter items: (1 to: 500).
presenter verticalAlignment desiredVisibleRow: 100.
self openInstance.

presenter verticalAlignment desiredVisibleRow: -1.

self assert: presenter verticalAlignment firstVisibleRowIndex equals: 1
]

{ #category : #'tests - scrolling' }
SpListCommonPropertiestTest >> testScrollUpToPreviousIndexScrollsTopToIndex [
self flag: #pharo7.
SystemVersion current major < 8 ifTrue: [ self skip. "Feature not supported in Pharo 7" ].
presenter items: (1 to: 500).
presenter verticalAlignment desiredVisibleRow: 100.
self openInstance.

presenter verticalAlignment desiredVisibleRow: 50.

self assert: presenter verticalAlignment firstVisibleRowIndex equals: 50
]

{ #category : #tests }
SpListCommonPropertiestTest >> testSetColumnTitleInPresenterPutsColumnHeaderMorph [

SystemVersion current major = 7
@@ -57,7 +113,7 @@ SpListCommonPropertiestTest >> testSetColumnTitleInPresenterPutsColumnHeaderMorp
backendForTest assertListHeaderOf: self adapter equals: #('test')
]

{ #category : #running }
{ #category : #tests }
SpListCommonPropertiestTest >> testSetColumnTitleInPresenterShowsThemInWidget [

self presenter headerTitle: 'test'.
@@ -4,13 +4,13 @@ Class {
#category : #'Spec2-Commander2-ContactBook-Spec'
}

{ #category : #hooks }
{ #category : #executing }
SpPrintContactBookInTranscript >> execute [
"Execute the actions that should be done by the command.
This method expect that the context has been put in #context inst. var. if any context is relevant."
Transcript open.
self contactBook contents do: [ :contact |
Transcript show: contact name; show: ' - '; show: contact name; cr ]

Smalltalk tools transcript open.
self contactBook contents do: [ :contact | self traceCr: contact name , ' - ' , contact name ]
]

{ #category : #initialization }
@@ -8,7 +8,8 @@ Class {
'#activationBlock',
'#activateOnSingleClick',
'#model',
'#itemFilter => SpObservableSlot'
'#itemFilter => SpObservableSlot',
'#verticalAlignment'
],
#category : #'Spec2-Core-Widgets-Table'
}
@@ -103,6 +104,7 @@ SpAbstractListPresenter >> initialize [
super initialize.

activationBlock := [ ].
verticalAlignment := SpVerticalAlignment new.

self withScrollBars.
self model: self newEmptyModel.
@@ -302,6 +304,11 @@ SpAbstractListPresenter >> unselectItem: anInteger [
self selection unselectItem: anInteger
]

{ #category : #accessing }
SpAbstractListPresenter >> verticalAlignment [
^ verticalAlignment
]

{ #category : #'api-events' }
SpAbstractListPresenter >> whenActivatedDo: aBlockClosure [

@@ -52,7 +52,7 @@ SpObservableSlot >> read: anObject [
]

{ #category : #initialization }
SpObservableSlot >> wantsInitalization [
SpObservableSlot >> wantsInitialization [

^ true
]
@@ -259,6 +259,19 @@ SpPresenter >> announce: anAnnouncement [
self announcer announce: anAnnouncement
]

{ #category : #'api-events' }
SpPresenter >> announceDisplayed [
"When using a VersatileDialogPresenter the adapter is nil.
We do not know if that is a correct behaviour"

self announcer
announce:
(SpWidgetDisplayed new
presenter: self;
widget: (adapter ifNotNil: [ adapter widget ]);
yourself)
]

{ #category : #accessing }
SpPresenter >> application [

@@ -650,6 +663,11 @@ SpPresenter >> instantiatePresenters: aCollectionOfPairs [
pairsDo: [ :k :v | self instVarNamed: k asString put: (self createInstanceFor: v) ] ]
]

{ #category : #api }
SpPresenter >> isBuilt [
^ self isDisplayed
]

{ #category : #api }
SpPresenter >> isDisplayed [
"Return true if the widget is currently displayed on screen"
@@ -1068,6 +1086,11 @@ SpPresenter >> visibleIf: aValuable [
visible := aValuable
]

{ #category : #'api-events' }
SpPresenter >> whenDisplayDo: aBlockClosure [
self announcer when: SpWidgetDisplayed do: aBlockClosure
]

{ #category : #'api-events' }
SpPresenter >> whenShortcutsChanged: aBlock [
"Set a block to value when the shortcuts block has changed"
@@ -60,7 +60,7 @@ SpVersatileDialogPresenter class >> example1 [
footnoteArea: 'This operation can be very dangerous.';
openModalWithSpec.
dialog withWindowDo: [ :w | w title: 'Confirmation' ].
dialog result logCr.
dialog result traceCr.

self inform: dialog moreOptionsArea state asString
]
@@ -78,7 +78,7 @@ SpVersatileDialogPresenter class >> example2 [
yourself.

dialog withWindowDo: [ :w | w title: 'Confirmation' ].
dialog result logCr
dialog result traceCr
]

{ #category : #specs }
@@ -99,7 +99,7 @@ SpVersatileDialogPresenter class >> example3 [
dialog openModalWithSpec.

dialog withWindowDo: [ :w | w title: 'Confirmation' ].
dialog result logCr
dialog result traceCr
]

{ #category : #specs }
@@ -115,7 +115,7 @@ SpVersatileDialogPresenter class >> example4 [
dialog openModalWithSpec.

dialog withWindowDo: [ :w | w title: 'Select number' ].
dialog result logCr
dialog result traceCr
]

{ #category : #specs }
@@ -137,7 +137,7 @@ SpVersatileDialogPresenter class >> example5 [
dialog openModalWithSpec.

dialog withWindowDo: [ :w | w title: 'Confirmation' ].
dialog result logCr
dialog result traceCr
]

{ #category : #api }

0 comments on commit ef8835a

Please sign in to comment.
You can’t perform that action at this time.