diff --git a/src/Spec2-Code/SpCodePresenter.class.st b/src/Spec2-Code/SpCodePresenter.class.st index 4a50bb8b6..3e502868c 100644 --- a/src/Spec2-Code/SpCodePresenter.class.st +++ b/src/Spec2-Code/SpCodePresenter.class.st @@ -320,18 +320,19 @@ SpCodePresenter >> doBrowseImplementors [ { #category : #commands } SpCodePresenter >> doBrowseMethodReferences [ "Browse references to Variables (Cmd-shift-n)" - | variableOrClassName variable usingMethods | + | variableOrClassName variable usingMethods | variableOrClassName := self selectedSelector ifNil: [ ^ nil ]. variable := self lookupEnvironment lookupVar: variableOrClassName. - variable ifNil: [ - ^ self doBrowseSenders ]. - usingMethods := variable usingMethods ifEmpty: [ ^ application inform: 'No users found.']. + variable ifNil: [ ^ self doBrowseSenders ]. + usingMethods := variable usingMethods ifEmpty: [ + ^ self inform: 'No users found.' ]. "the dialog sadly hard-codes 'senders'" - ^ self systemNavigation openBrowserFor: variable name withMethods: usingMethods - + ^ self systemNavigation + openBrowserFor: variable name + withMethods: usingMethods ] { #category : #commands } diff --git a/src/Spec2-Dialogs/SpConfirmDialog.class.st b/src/Spec2-Dialogs/SpConfirmDialog.class.st index cfbcecd61..d40c37b70 100644 --- a/src/Spec2-Dialogs/SpConfirmDialog.class.st +++ b/src/Spec2-Dialogs/SpConfirmDialog.class.st @@ -58,31 +58,36 @@ SpConfirmDialog class >> documentFactoryMethodSelector [ { #category : #examples } SpConfirmDialog class >> example [ - ^ self new - title: 'Confirm example'; - label: 'Are you sure?'; - acceptLabel: 'Sure!'; - cancelLabel: 'No, forget it'; - label: 'Are you sure?'; - onAccept: [ self inform: 'Yes!' ]; - onCancel: [ self inform: 'No!' ]; - openDialog + | dialog | + dialog := self new. + ^ dialog + title: 'Confirm example'; + label: 'Are you sure?'; + acceptLabel: 'Sure!'; + cancelLabel: 'No, forget it'; + label: 'Are you sure?'; + onAccept: [ + dialog inform: 'Yes!' ]; + onCancel: [ + dialog inform: 'No!' ]; + openDialog ] { #category : #examples } SpConfirmDialog class >> exampleModal [ - | ok | - - ok := self new - title: 'Confirm modal example'; - label: 'Are you sure?'; - acceptLabel: 'Sure!'; - cancelLabel: 'No, forget it'; - openModal. - - self inform: (ok - ifTrue: [ 'Yes!' ] - ifFalse: [ 'No!' ]) + + | ok dialog | + dialog := self new. + ok := dialog + title: 'Confirm modal example'; + label: 'Are you sure?'; + acceptLabel: 'Sure!'; + cancelLabel: 'No, forget it'; + openModal. + + dialog inform: (ok + ifTrue: [ 'Yes!' ] + ifFalse: [ 'No!' ]) ] { #category : #api } diff --git a/src/Spec2-Dialogs/SpRequestDialog.class.st b/src/Spec2-Dialogs/SpRequestDialog.class.st index b53667048..a637415fa 100644 --- a/src/Spec2-Dialogs/SpRequestDialog.class.st +++ b/src/Spec2-Dialogs/SpRequestDialog.class.st @@ -48,30 +48,32 @@ SpRequestDialog class >> documentFactoryMethodSelector [ { #category : #examples } SpRequestDialog class >> example [ - self new + | presenter | + presenter := self new. + presenter title: 'Request example'; label: 'The meaning of life?'; text: 'I am tempted to say 42...'; acceptLabel: 'I know!'; cancelLabel: 'Cancel'; - onAccept: [ :dialog | self inform: dialog presenter text ]; + onAccept: [ :dialog | dialog presenter inform: dialog presenter text ]; openDialog ] { #category : #examples } SpRequestDialog class >> exampleModal [ - | string | - string := self new - title: 'Request modal example'; - label: 'The meaning of life?'; - text: 'I am tempted to say 42...'; - acceptLabel: 'I know!'; - cancelLabel: 'Cancel'; - openModal. - - string ifNotNil: [ - self inform: string ] + | string presenter | + presenter := self new. + string := presenter + title: 'Request modal example'; + label: 'The meaning of life?'; + text: 'I am tempted to say 42...'; + acceptLabel: 'I know!'; + cancelLabel: 'Cancel'; + openModal. + + string ifNotNil: [ presenter inform: string ] ] { #category : #visiting } diff --git a/src/Spec2-Dialogs/SpSelectDialog.class.st b/src/Spec2-Dialogs/SpSelectDialog.class.st index 2be4a8075..571074b7a 100644 --- a/src/Spec2-Dialogs/SpSelectDialog.class.st +++ b/src/Spec2-Dialogs/SpSelectDialog.class.st @@ -41,30 +41,34 @@ SpSelectDialog class >> documentFactoryMethodSelector [ { #category : #examples } SpSelectDialog class >> example [ - self new + | presenter | + presenter := self new. + presenter title: 'Select example'; label: 'Select a class'; items: Smalltalk allClassesAndTraits; display: [ :each | each name ]; displayIcon: [ :each | self iconNamed: each systemIconName ]; - onAccept: [ :dialog | self inform: dialog presenter selectedItem asString ]; + onAccept: [ :dialog | + dialog presenter inform: dialog presenter selectedItem asString ]; openDialog ] { #category : #examples } SpSelectDialog class >> exampleModal [ - | selection | - selection := self new - title: 'Select modal example'; - label: 'Select a class'; - items: Smalltalk allClassesAndTraits; - display: [ :each | each name ]; - displayIcon: [ :each | self iconNamed: each systemIconName ]; - openModal. - - selection ifNotNil: [ - self inform: selection asString ] + | dialog selection | + dialog := self new. + selection := dialog + title: 'Select modal example'; + label: 'Select a class'; + items: Smalltalk allClassesAndTraits; + display: [ :each | each name ]; + displayIcon: [ :each | + self iconNamed: each systemIconName ]; + openModal. + + selection ifNotNil: [ dialog inform: selection asString ] ] { #category : #api } diff --git a/src/Spec2-Examples/SpBoxLayout.extension.st b/src/Spec2-Examples/SpBoxLayout.extension.st index d4ba01e9c..00bb76843 100644 --- a/src/Spec2-Examples/SpBoxLayout.extension.st +++ b/src/Spec2-Examples/SpBoxLayout.extension.st @@ -105,106 +105,99 @@ SpBoxLayout class >> exampleExpand [ { #category : #'*Spec2-Examples' } SpBoxLayout class >> exampleHAlignCenter [ - | presenter | + | presenter | presenter := SpPresenter new. presenter layout: (self newTopToBottom - hAlignCenter; - add: (presenter newButton - icon: (presenter application iconNamed: #smallOk); - label: 'Press me!'; - action: [ presenter application inform: 'Pressed!' ]) - yourself). + hAlignCenter; + add: (presenter newButton + icon: (presenter application iconNamed: #smallOk); + label: 'Press me!'; + action: [ presenter inform: 'Pressed!' ]) yourself). presenter open ] { #category : #'*Spec2-Examples' } SpBoxLayout class >> exampleHAlignEnd [ - | presenter | + | presenter | presenter := SpPresenter new. presenter layout: (self newTopToBottom - hAlignEnd; - add: (presenter newButton - icon: (presenter application iconNamed: #smallOk); - label: 'Press me!'; - action: [ presenter application inform: 'Pressed!' ]) - yourself). + hAlignEnd; + add: (presenter newButton + icon: (presenter application iconNamed: #smallOk); + label: 'Press me!'; + action: [ presenter inform: 'Pressed!' ]) yourself). presenter open ] { #category : #'*Spec2-Examples' } SpBoxLayout class >> exampleHAlignStart [ - | presenter | + | presenter | presenter := SpPresenter new. presenter layout: (self newTopToBottom - hAlignStart; - add: (presenter newButton - icon: (presenter application iconNamed: #smallOk); - label: 'Press me!'; - action: [ presenter application inform: 'Pressed!' ]) - yourself). + hAlignStart; + add: (presenter newButton + icon: (presenter application iconNamed: #smallOk); + label: 'Press me!'; + action: [ presenter inform: 'Pressed!' ]) yourself). presenter open ] { #category : #'*Spec2-Examples' } SpBoxLayout class >> exampleVAlignAndHAlign [ - | presenter | + | presenter | presenter := SpPresenter new. presenter layout: (self newTopToBottom - vAlignCenter; - hAlignCenter; - add: (presenter newButton - icon: (presenter application iconNamed: #smallOk); - label: 'Press me!'; - action: [ presenter application inform: 'Pressed!' ]) - yourself). + vAlignCenter; + hAlignCenter; + add: (presenter newButton + icon: (presenter application iconNamed: #smallOk); + label: 'Press me!'; + action: [ presenter inform: 'Pressed!' ]) yourself). presenter open ] { #category : #'*Spec2-Examples' } SpBoxLayout class >> exampleVAlignCenter [ - | presenter | + | presenter | presenter := SpPresenter new. presenter layout: (self newTopToBottom - vAlignCenter; - add: (presenter newButton - icon: (presenter application iconNamed: #smallOk); - label: 'Press me!'; - action: [ presenter application inform: 'Pressed!' ]) - yourself). + vAlignCenter; + add: (presenter newButton + icon: (presenter application iconNamed: #smallOk); + label: 'Press me!'; + action: [ presenter inform: 'Pressed!' ]) yourself). presenter open ] { #category : #'*Spec2-Examples' } SpBoxLayout class >> exampleVAlignEnd [ - | presenter | + | presenter | presenter := SpPresenter new. presenter layout: (self newTopToBottom - vAlignEnd; - add: (presenter newButton - icon: (presenter application iconNamed: #smallOk); - label: 'Press me!'; - action: [ presenter application inform: 'Pressed!' ]) - yourself). + vAlignEnd; + add: (presenter newButton + icon: (presenter application iconNamed: #smallOk); + label: 'Press me!'; + action: [ presenter inform: 'Pressed!' ]) yourself). presenter open ] { #category : #'*Spec2-Examples' } SpBoxLayout class >> exampleVAlignStart [ - | presenter | + | presenter | presenter := SpPresenter new. presenter layout: (self newTopToBottom - vAlignStart; - add: (presenter newButton - icon: (presenter application iconNamed: #smallOk); - label: 'Press me!'; - action: [ presenter application inform: 'Pressed!' ]) - yourself). + vAlignStart; + add: (presenter newButton + icon: (presenter application iconNamed: #smallOk); + label: 'Press me!'; + action: [ presenter inform: 'Pressed!' ]) yourself). presenter open ] diff --git a/src/Spec2-Examples/SpDemoActionBarPresenter.class.st b/src/Spec2-Examples/SpDemoActionBarPresenter.class.st index 899e4e435..9c79dc8d1 100644 --- a/src/Spec2-Examples/SpDemoActionBarPresenter.class.st +++ b/src/Spec2-Examples/SpDemoActionBarPresenter.class.st @@ -22,26 +22,29 @@ SpDemoActionBarPresenter >> defaultLayout [ { #category : #initialization } SpDemoActionBarPresenter >> initializePresenters [ - + actionBar := self newActionBar - add: (self newButton - label: 'Add'; - icon: (self iconNamed: #smallOk); - help: 'Add.'; - action: [ UIManager default defer: [ self inform: 'Add' ] ]; - yourself); - add: (self newButton - label: 'Remove'; - icon: (self iconNamed: #smallCancel); - help: 'Remove.'; - action: [ UIManager default defer: [ self inform: 'Remove' ] ]; - yourself); - addLast: (self newButton - label: 'Other'; - help: 'Other.'; - action: [ UIManager default defer: [ self inform: 'Other' ] ]; - yourself); - yourself. + add: (self newButton + label: 'Add'; + icon: (self iconNamed: #smallOk); + help: 'Add.'; + action: [ + actionBar defer: [ self inform: 'Add' ] ]; + yourself); + add: (self newButton + label: 'Remove'; + icon: (self iconNamed: #smallCancel); + help: 'Remove.'; + action: [ + actionBar defer: [ self inform: 'Remove' ] ]; + yourself); + addLast: (self newButton + label: 'Other'; + help: 'Other.'; + action: [ + actionBar defer: [ self inform: 'Other' ] ]; + yourself); + yourself. text := self newText ] diff --git a/src/Spec2-Examples/SpDemoModal1Presenter.class.st b/src/Spec2-Examples/SpDemoModal1Presenter.class.st index d9fa33d62..6d0a157aa 100644 --- a/src/Spec2-Examples/SpDemoModal1Presenter.class.st +++ b/src/Spec2-Examples/SpDemoModal1Presenter.class.st @@ -17,6 +17,7 @@ SpDemoModal1Presenter >> content [ { #category : #initialization } SpDemoModal1Presenter >> initializeDialogWindow: aDialog [ + super initializeDialogWindow: aDialog. aDialog closeOnBackdropClick: true; diff --git a/src/Spec2-Examples/SpDemoModal2Presenter.class.st b/src/Spec2-Examples/SpDemoModal2Presenter.class.st index ce2579619..b6dc2f3e0 100644 --- a/src/Spec2-Examples/SpDemoModal2Presenter.class.st +++ b/src/Spec2-Examples/SpDemoModal2Presenter.class.st @@ -17,16 +17,16 @@ SpDemoModal2Presenter >> content [ { #category : #initialization } SpDemoModal2Presenter >> initializeDialogWindow: aDialog [ + aDialog closeOnBackdropClick: false; - addButton: 'Validate' - do: [ :presenter | + addButton: 'Validate' do: [ :presenter | self inform: 'Validate'. presenter close ]; addButton: 'Reset' - do: [ :presenter | self inform: 'This action does not close the modal' ]; - addButton: 'Cancel' - do: [ :presenter | + do: [ :presenter | + self inform: 'This action does not close the modal' ]; + addButton: 'Cancel' do: [ :presenter | self inform: 'Cancel'. presenter close ] ] diff --git a/src/Spec2-Examples/SpDemoSelectablePresenter.class.st b/src/Spec2-Examples/SpDemoSelectablePresenter.class.st index e6bb65e04..8ab330d32 100644 --- a/src/Spec2-Examples/SpDemoSelectablePresenter.class.st +++ b/src/Spec2-Examples/SpDemoSelectablePresenter.class.st @@ -7,13 +7,13 @@ Class { } { #category : #'instance creation' } -SpDemoSelectablePresenter class >> open [ +SpDemoSelectablePresenter class >> open [ +