diff --git a/src/Toplo-Serialization-Stash/TToCheckable.extension.st b/src/Toplo-Serialization-Stash/TToCheckable.extension.st index 947f1e9..541cbb1 100644 --- a/src/Toplo-Serialization-Stash/TToCheckable.extension.st +++ b/src/Toplo-Serialization-Stash/TToCheckable.extension.st @@ -5,9 +5,12 @@ TToCheckable >> stashAccessorsForTToCheckable [ | settersAndGetters | + self class == ToTab ifTrue: [ ^ { } ]. self isCheckable ifFalse: [ ^ { } ]. + settersAndGetters := OrderedCollection new. - settersAndGetters add: #initializeCheckable onlySetOnStash. + + self class == ToToggleButton ifFalse: [ settersAndGetters add: #initializeCheckable onlySetOnStash ]. self checked ifTrue: [ settersAndGetters add: #checked ]. self group ifNotNil: [ settersAndGetters add: #group ]. ^ settersAndGetters diff --git a/src/Toplo-Serialization-Stash/ToTab.extension.st b/src/Toplo-Serialization-Stash/ToTab.extension.st new file mode 100644 index 0000000..11a9519 --- /dev/null +++ b/src/Toplo-Serialization-Stash/ToTab.extension.st @@ -0,0 +1,32 @@ +Extension { #name : #ToTab } + +{ #category : #'*Toplo-Serialization-Stash' } +ToTab >> firstElement [ + + | first | + first := self children first. + first == filler ifTrue: [ ^ nil ]. + ^ first +] + +{ #category : #'*Toplo-Serialization-Stash' } +ToTab >> firstElement: anElement [ + + anElement ifNil: [ ^ self ]. + self addChild: anElement at: 1 +] + +{ #category : #'*Toplo-Serialization-Stash' } +ToTab >> stashElement [ + + + self firstElement ifNil: [ ^ { } ]. + ^ { (#firstElement: -> #firstElement) } +] + +{ #category : #'*Toplo-Serialization-Stash' } +ToTab >> stashPaneBuilder [ + + + ^ { #paneBuilder } +] diff --git a/src/Toplo-Serialization-Stash/ToTabPane.extension.st b/src/Toplo-Serialization-Stash/ToTabPane.extension.st new file mode 100644 index 0000000..e46b04d --- /dev/null +++ b/src/Toplo-Serialization-Stash/ToTabPane.extension.st @@ -0,0 +1,14 @@ +Extension { #name : #ToTabPane } + +{ #category : #'*Toplo-Serialization-Stash' } +ToTabPane >> stashAddAllTabs: aCollectionOfTabs [ + + aCollectionOfTabs do: [ :each | self addTab: each ]. +] + +{ #category : #'*Toplo-Serialization-Stash' } +ToTabPane >> stashTabs [ + + + ^ { #stashAddAllTabs: -> #tabs } +] diff --git a/src/Toplo-Serialization-Tests/ToSerializerTest.class.st b/src/Toplo-Serialization-Tests/ToSerializerTest.class.st index 97d317e..8d6a50c 100644 --- a/src/Toplo-Serialization-Tests/ToSerializerTest.class.st +++ b/src/Toplo-Serialization-Tests/ToSerializerTest.class.st @@ -353,6 +353,119 @@ ToSerializerTest >> testToLabel [ on: [ :element | self assert: element text asString equals: 'hello' ] ] +{ #category : #tests } +ToSerializerTest >> testToTabPane1 [ + + | origin | + origin := ToTabPane new. + origin resizablePanes: true. + 1 to: 3 do: [ :index | | tab | + tab := ToTab new. + tab closable: true. + tab labelText: 'Button ' , index asString. + tab paneBuilder: [ :pane :theNoteBook | + pane background: Color random ]. + origin addTab: tab ]. + + self test: origin on: [ :element | + self assert: element tabs size equals: 3 ] +] + +{ #category : #tests } +ToSerializerTest >> testToTabPane2 [ + + | origin | + origin := ToTabPane new. + origin resizablePanes: true. + 1 to: 100 do: [ :index | + | tab | + tab := ToTab new. + tab closable: true. + tab labelText: 'Button ' , index asString. + tab paneBuilder: [ :pane :theNoteBook | + pane background: Color random ]. + origin addTab: tab ]. + + self + test: origin + on: [ :element | self assert: element tabs size equals: 100 ] +] + +{ #category : #tests } +ToSerializerTest >> testToTabPane3 [ + + | origin | + origin := ToTabPane new. + origin resizablePanes: true. + 1 to: 0 do: [ :index | + | tab | + tab := ToTab new. + tab closable: true. + tab labelText: 'Button ' , index asString. + tab paneBuilder: [ :pane :theNoteBook | + pane background: Color random ]. + origin addTab: tab ]. + + self + test: origin + on: [ :element | self assert: element tabs size equals: 0 ] +] + +{ #category : #tests } +ToSerializerTest >> testToTabPane4 [ + + | origin | + origin := ToTabPane new. + origin resizablePanes: true. + 1 to: 3 do: [ :index | + | tab | + tab := ToTab new. + tab closable: true. + tab labelText: 'Button ' , index asString. + tab paneBuilder: [ :pane :theNoteBook | + pane background: Color random ]. + origin addTab: tab ]. + + self test: origin on: [ :element | + self assert: element tabs size equals: 3. + self + assert: element tabs first firstElement text asString + equals: 'Button 1'. + self + assert: element tabs second firstElement text asString + equals: 'Button 2'. + self + assert: element tabs third firstElement text asString + equals: 'Button 3' ] +] + +{ #category : #tests } +ToSerializerTest >> testToTabPane5 [ + + | origin | + origin := ToTabPane new. + origin resizablePanes: true. + 1 to: 3 do: [ :index | + | tab | + tab := ToTab new. + tab closable: true. + tab labelText: 'Button ' , index asString. + tab paneBuilder: [ :pane :theNoteBook | #test ]. + origin addTab: tab ]. + + self test: origin on: [ :element | + self assert: element tabs size equals: 3. + self + assert: (element tabs first paneBuilder value: nil value: nil) + equals: #test. + self + assert: (element tabs second paneBuilder value: nil value: nil) + equals: #test. + self + assert: (element tabs third paneBuilder value: nil value: nil) + equals: #test ] +] + { #category : #tests } ToSerializerTest >> testTokens [