Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ToTab and ToTabPane #7

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Toplo-Serialization-Stash/TToCheckable.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ TToCheckable >> stashAccessorsForTToCheckable [

<stashAccessors>
| 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
Expand Down
32 changes: 32 additions & 0 deletions src/Toplo-Serialization-Stash/ToTab.extension.st
Original file line number Diff line number Diff line change
@@ -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 [

<stashAccessors>
self firstElement ifNil: [ ^ { } ].
^ { (#firstElement: -> #firstElement) }
]

{ #category : #'*Toplo-Serialization-Stash' }
ToTab >> stashPaneBuilder [

<stashAccessors>
^ { #paneBuilder }
]
14 changes: 14 additions & 0 deletions src/Toplo-Serialization-Stash/ToTabPane.extension.st
Original file line number Diff line number Diff line change
@@ -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 [

<stashAccessors>
^ { #stashAddAllTabs: -> #tabs }
]
113 changes: 113 additions & 0 deletions src/Toplo-Serialization-Tests/ToSerializerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -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 [

Expand Down
Loading