Skip to content

Commit

Permalink
spec layouts should now be on instance side
Browse files Browse the repository at this point in the history
  • Loading branch information
demarey committed Oct 17, 2024
1 parent 5774572 commit a59f7c8
Show file tree
Hide file tree
Showing 15 changed files with 211 additions and 195 deletions.
62 changes: 32 additions & 30 deletions source/Teapot-Tools/Cupboard.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ You can open me with:
self soleInstance open
"
Class {
#name : #Cupboard,
#superclass : #SpPresenter,
#name : 'Cupboard',
#superclass : 'SpPresenter',
#instVars : [
'teapots',
'toolbar'
Expand All @@ -17,16 +17,18 @@ Class {
'soleInstance',
'icons'
],
#category : #'Teapot-Tools-UI'
#category : 'Teapot-Tools-UI',
#package : 'Teapot-Tools',
#tag : 'UI'
}

{ #category : #accessing }
{ #category : 'accessing' }
Cupboard class >> iconProvider [

^TeaIconProvider
]

{ #category : #'world menu' }
{ #category : 'world menu' }
Cupboard class >> menuCommandOn: aBuilder [
<worldMenu>

Expand All @@ -38,28 +40,28 @@ Cupboard class >> menuCommandOn: aBuilder [
aBuilder withSeparatorAfter
]

{ #category : #'instance creation' }
{ #category : 'instance creation' }
Cupboard class >> new [

self error: 'Do not create new instances - access using #soleInstance'
]

{ #category : #private }
{ #category : 'private' }
Cupboard class >> reset [
<script>

soleInstance := nil.

]

{ #category : #accessing }
{ #category : 'accessing' }
Cupboard class >> soleInstance [
<script: 'self soleInstance inspect'>

^ soleInstance ifNil: [ soleInstance := self basicNew initialize ]
]

{ #category : #initialization }
{ #category : 'initialization' }
Cupboard >> buildBrowseToolBarItem [

^ SpToolbarButtonPresenter new
Expand All @@ -70,7 +72,7 @@ Cupboard >> buildBrowseToolBarItem [
yourself
]

{ #category : #initialization }
{ #category : 'initialization' }
Cupboard >> buildContextMenu [

^ SpMenuPresenter new
Expand All @@ -92,7 +94,7 @@ Cupboard >> buildContextMenu [
yourself
]

{ #category : #initialization }
{ #category : 'initialization' }
Cupboard >> buildInspectToolBarItem [

^ SpToolbarButtonPresenter new
Expand All @@ -103,7 +105,7 @@ Cupboard >> buildInspectToolBarItem [
yourself
]

{ #category : #initialization }
{ #category : 'initialization' }
Cupboard >> buildNewStaticToolBarItem [

^ SpToolbarButtonPresenter new
Expand All @@ -116,7 +118,7 @@ Cupboard >> buildNewStaticToolBarItem [
yourself
]

{ #category : #initialization }
{ #category : 'initialization' }
Cupboard >> buildNewToolBarItem [

^ SpToolbarButtonPresenter new
Expand All @@ -129,7 +131,7 @@ Cupboard >> buildNewToolBarItem [
yourself
]

{ #category : #initialization }
{ #category : 'initialization' }
Cupboard >> buildRefreshToolBarItem [

^ SpToolbarButtonPresenter new
Expand All @@ -140,7 +142,7 @@ Cupboard >> buildRefreshToolBarItem [
yourself
]

{ #category : #initialization }
{ #category : 'initialization' }
Cupboard >> buildStartToolBarItem [

^ SpToolbarButtonPresenter new
Expand All @@ -151,7 +153,7 @@ Cupboard >> buildStartToolBarItem [
yourself
]

{ #category : #initialization }
{ #category : 'initialization' }
Cupboard >> buildStopToolBarItem [

^ SpToolbarButtonPresenter new
Expand All @@ -162,7 +164,7 @@ Cupboard >> buildStopToolBarItem [
yourself
]

{ #category : #initialization }
{ #category : 'initialization' }
Cupboard >> buildToolbar [

^ self newToolbar
Expand All @@ -176,27 +178,27 @@ Cupboard >> buildToolbar [
yourself
]

{ #category : #layout }
{ #category : 'layout' }
Cupboard >> defaultLayout [

^ SpBoxLayout newTopToBottom
add: teapots;
yourself
]

{ #category : #private }
{ #category : 'private' }
Cupboard >> iconForTeapot: aTeapot [
^aTeapot server isRunning
ifTrue: [ self iconProvider teapotServerStartIcon ]
ifFalse: [ self iconProvider teapotServerStopIcon ]
]

{ #category : #accessing }
{ #category : 'accessing' }
Cupboard >> iconProvider [
^ self class iconProvider
]

{ #category : #initialization }
{ #category : 'initialization' }
Cupboard >> initializePresenters [

teapots := self newList.
Expand All @@ -209,7 +211,7 @@ Cupboard >> initializePresenters [
contextMenu: self buildContextMenu
]

{ #category : #initialization }
{ #category : 'initialization' }
Cupboard >> initializeWindow: aWindowPresenter [

super initializeWindow: aWindowPresenter.
Expand All @@ -218,7 +220,7 @@ Cupboard >> initializeWindow: aWindowPresenter [
toolbar: (toolbar := self buildToolbar).
]

{ #category : #private }
{ #category : 'private' }
Cupboard >> nameForTeapot: aTeapot [
^ String streamContents: [:stream |
stream nextPutAll: aTeapot server port asString.
Expand All @@ -227,7 +229,7 @@ Cupboard >> nameForTeapot: aTeapot [

]

{ #category : #actions }
{ #category : 'actions' }
Cupboard >> onNewServer [
| port pot |
port := UIManager default request: 'New server' initialAnswer: '80'.
Expand All @@ -241,7 +243,7 @@ Cupboard >> onNewServer [

]

{ #category : #actions }
{ #category : 'actions' }
Cupboard >> onNewStaticServer [
| port directory pot |
port := UIManager default request: 'New server' initialAnswer: '80'.
Expand All @@ -258,31 +260,31 @@ Cupboard >> onNewStaticServer [

]

{ #category : #actions }
{ #category : 'actions' }
Cupboard >> open [

self refreshTeapots.
super open.
]

{ #category : #printing }
{ #category : 'printing' }
Cupboard >> printOn: aStream [
aStream nextPutAll: 'Cupboard'
]

{ #category : #actions }
{ #category : 'actions' }
Cupboard >> refreshTeapots [

teapots items: self teapots
]

{ #category : #accessing }
{ #category : 'accessing' }
Cupboard >> selectedTeapot [

^ teapots selectedItem
]

{ #category : #accessing }
{ #category : 'accessing' }
Cupboard >> teapots [
^ Teapot allInstances
]
10 changes: 6 additions & 4 deletions source/Teapot-Tools/ManifestTeapotTools.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
Please describe the package using the class comment of the included manifest class. The manifest class also includes other additional metadata for the package. These meta data are used by other tools such as the SmalllintManifestChecker and the critics Browser
"
Class {
#name : #ManifestTeapotTools,
#superclass : #PackageManifest,
#category : #'Teapot-Tools-Manifest'
#name : 'ManifestTeapotTools',
#superclass : 'PackageManifest',
#category : 'Teapot-Tools-Manifest',
#package : 'Teapot-Tools',
#tag : 'Manifest'
}

{ #category : #'code-critics' }
{ #category : 'code-critics' }
ManifestTeapotTools class >> ruleLongMethodsRuleV1FalsePositive [
^ #(#(#(#RGMethodDefinition #(#Cupboard #inspectTeapot: #false)) #'2022-08-29T16:00:19.64012+02:00') )
]
44 changes: 23 additions & 21 deletions source/Teapot-Tools/TeaFormTab.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,44 @@
I'm built up from a dynamically extensible key value pair list (TeaKeyValueInput). I can represent POST parameters or HTTP headers for example.
"
Class {
#name : #TeaFormTab,
#superclass : #SpPresenter,
#name : 'TeaFormTab',
#superclass : 'SpPresenter',
#instVars : [
'form',
'addButton'
],
#category : #'Teapot-Tools-UI-Components'
#category : 'Teapot-Tools-UI-Components',
#package : 'Teapot-Tools',
#tag : 'UI-Components'
}

{ #category : #specs }
TeaFormTab class >> defaultLayout [
^ SpBoxLayout newVertical
add: #form expand: false fill: false;
add: (SpBoxLayout newHorizontal
add: #addButton expand: false fill: false;
hAlignCenter;
yourself) expand: false fill: false;
yourself
]

{ #category : #accessing }
{ #category : 'accessing' }
TeaFormTab >> addButton [
^ addButton
]

{ #category : #initialization }
{ #category : 'initialization' }
TeaFormTab >> connectPresenters [
addButton whenActionPerformedDo: [ form addKey: 'key' value: 'value' ]
]

{ #category : #accessing }
{ #category : 'layout' }
TeaFormTab >> defaultLayout [
^ SpBoxLayout newVertical
add: form expand: false fill: false;
add: (SpBoxLayout newHorizontal
add: addButton expand: false fill: false;
hAlignCenter;
yourself) expand: false fill: false;
yourself
]

{ #category : 'accessing' }
TeaFormTab >> form [
^ form
]

{ #category : #initialization }
{ #category : 'initialization' }
TeaFormTab >> initializePresenters [
addButton := self newButton label: 'Add parameter'; yourself.
form := self instantiate: TeaKeyValueList.
Expand All @@ -46,12 +48,12 @@ TeaFormTab >> initializePresenters [
add: addButton.
]

{ #category : #protocol }
{ #category : 'protocol' }
TeaFormTab >> updateKeyValus: keyValueCollection [
form items: keyValueCollection
]

{ #category : #private }
{ #category : 'private' }
TeaFormTab >> urlEncoded [
| url formParams |
url := '/' asZnUrl.
Expand All @@ -62,7 +64,7 @@ TeaFormTab >> urlEncoded [

]

{ #category : #protocol }
{ #category : 'protocol' }
TeaFormTab >> writeUrlEncodedTo: aTextModel [
self urlEncoded
ifNotEmpty: [ aTextModel text: self urlEncoded ]
Expand Down
4 changes: 2 additions & 2 deletions source/Teapot-Tools/TeaGlobUrlPattern.extension.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #TeaGlobUrlPattern }
Extension { #name : 'TeaGlobUrlPattern' }

{ #category : #'*Teapot-Tools' }
{ #category : '*Teapot-Tools' }
TeaGlobUrlPattern >> asTeaspoonPath [
^ String streamContents: [ :aStream |
segments
Expand Down
Loading

0 comments on commit a59f7c8

Please sign in to comment.